@@ -1180,7 +1180,8 @@ enum class TranslationSemantics {
11801180 // / getUnderlyingTrackedValue can look through the instruction.
11811181 LookThrough,
11821182
1183- // / Emit require partition ops for each operand of the instruction.
1183+ // / Require that the region associated with a value not be consumed at this
1184+ // / program point.
11841185 Require,
11851186
11861187 // / A "CopyLikeInstruction" with a Dest and Src operand value. If the store
@@ -1208,6 +1209,13 @@ enum class TranslationSemantics {
12081209 // / A terminator instruction that acts like a phi in terms of its region.
12091210 TerminatorPhi,
12101211
1212+ // / An instruction that we should never see and if we do see, we should assert
1213+ // / upon. This is generally used for non-Ownership SSA instructions and
1214+ // / instructions that can only appear in Lowered SIL. Even if we should never
1215+ // / see one of these instructions, we would still like to ensure that we
1216+ // / handle every instruction to ensure we cover the IR.
1217+ Asserting,
1218+
12111219 // / An instruction that we do not handle yet. Just for now during bring
12121220 // / up. Will be removed.
12131221 Unhandled,
@@ -1247,6 +1255,9 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
12471255 case TranslationSemantics::TerminatorPhi:
12481256 os << " terminator_phi" ;
12491257 return os;
1258+ case TranslationSemantics::Asserting:
1259+ os << " asserting" ;
1260+ return os;
12501261 case TranslationSemantics::Unhandled:
12511262 os << " unhandled" ;
12521263 return os;
@@ -2152,6 +2163,11 @@ class PartitionOpTranslator {
21522163 return translateSILPhi (sources);
21532164 }
21542165
2166+ case TranslationSemantics::Asserting:
2167+ llvm::report_fatal_error (
2168+ " transfer-non-sendable: Found banned instruction?!" );
2169+ return ;
2170+
21552171 case TranslationSemantics::Unhandled:
21562172 LLVM_DEBUG (llvm::dbgs () << " Unhandled inst: " << *inst);
21572173 return ;
@@ -2449,18 +2465,9 @@ CONSTANT_TRANSLATION(DeallocStackRefInst, Unhandled)
24492465CONSTANT_TRANSLATION(DeallocRefInst, Unhandled)
24502466CONSTANT_TRANSLATION(DeallocPartialRefInst, Unhandled)
24512467CONSTANT_TRANSLATION(DeallocExistentialBoxInst, Unhandled)
2452- CONSTANT_TRANSLATION(StrongRetainInst, Unhandled)
2453- CONSTANT_TRANSLATION(StrongReleaseInst, Unhandled)
24542468CONSTANT_TRANSLATION(UnmanagedRetainValueInst, Unhandled)
24552469CONSTANT_TRANSLATION(UnmanagedReleaseValueInst, Unhandled)
24562470CONSTANT_TRANSLATION(UnmanagedAutoreleaseValueInst, Unhandled)
2457- CONSTANT_TRANSLATION(StrongRetainUnownedInst, Unhandled)
2458- CONSTANT_TRANSLATION(UnownedRetainInst, Unhandled)
2459- CONSTANT_TRANSLATION(UnownedReleaseInst, Unhandled)
2460- CONSTANT_TRANSLATION(RetainValueInst, Unhandled)
2461- CONSTANT_TRANSLATION(RetainValueAddrInst, Unhandled)
2462- CONSTANT_TRANSLATION(ReleaseValueInst, Unhandled)
2463- CONSTANT_TRANSLATION(ReleaseValueAddrInst, Unhandled)
24642471CONSTANT_TRANSLATION(AutoreleaseValueInst, Unhandled)
24652472CONSTANT_TRANSLATION(FixLifetimeInst, Unhandled)
24662473CONSTANT_TRANSLATION(BeginUnpairedAccessInst, Unhandled)
@@ -2491,6 +2498,18 @@ CONSTANT_TRANSLATION(CondBranchInst, TerminatorPhi)
24912498CONSTANT_TRANSLATION(CheckedCastBranchInst, TerminatorPhi)
24922499CONSTANT_TRANSLATION(DynamicMethodBranchInst, TerminatorPhi)
24932500
2501+ // Non-OSSA instructions that we should never see since we bail on non-OSSA
2502+ // functions early.
2503+ CONSTANT_TRANSLATION(ReleaseValueAddrInst, Asserting)
2504+ CONSTANT_TRANSLATION(ReleaseValueInst, Asserting)
2505+ CONSTANT_TRANSLATION(RetainValueAddrInst, Asserting)
2506+ CONSTANT_TRANSLATION(RetainValueInst, Asserting)
2507+ CONSTANT_TRANSLATION(StrongReleaseInst, Asserting)
2508+ CONSTANT_TRANSLATION(StrongRetainInst, Asserting)
2509+ CONSTANT_TRANSLATION(StrongRetainUnownedInst, Asserting)
2510+ CONSTANT_TRANSLATION(UnownedReleaseInst, Asserting)
2511+ CONSTANT_TRANSLATION(UnownedRetainInst, Asserting)
2512+
24942513#undef CONSTANT_TRANSLATION
24952514
24962515#ifdef LOOKTHROUGH_IF_NONSENDABLE_RESULT_REQUIRE_OTHERWISE
@@ -3293,6 +3312,11 @@ class TransferNonSendable : public SILFunctionTransform {
32933312 return ;
32943313 }
32953314
3315+ if (!function->hasOwnership ()) {
3316+ LLVM_DEBUG (llvm::dbgs () << " Only runs on Ownership SSA, skipping!\n " );
3317+ return ;
3318+ }
3319+
32963320 // The sendable protocol should /always/ be available if TransferNonSendable
32973321 // is enabled. If not, there is a major bug in the compiler and we should
32983322 // fail loudly.
0 commit comments