@@ -1180,7 +1180,8 @@ enum class TranslationSemantics {
1180
1180
// / getUnderlyingTrackedValue can look through the instruction.
1181
1181
LookThrough,
1182
1182
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.
1184
1185
Require,
1185
1186
1186
1187
// / A "CopyLikeInstruction" with a Dest and Src operand value. If the store
@@ -1208,6 +1209,13 @@ enum class TranslationSemantics {
1208
1209
// / A terminator instruction that acts like a phi in terms of its region.
1209
1210
TerminatorPhi,
1210
1211
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
+
1211
1219
// / An instruction that we do not handle yet. Just for now during bring
1212
1220
// / up. Will be removed.
1213
1221
Unhandled,
@@ -1247,6 +1255,9 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
1247
1255
case TranslationSemantics::TerminatorPhi:
1248
1256
os << " terminator_phi" ;
1249
1257
return os;
1258
+ case TranslationSemantics::Asserting:
1259
+ os << " asserting" ;
1260
+ return os;
1250
1261
case TranslationSemantics::Unhandled:
1251
1262
os << " unhandled" ;
1252
1263
return os;
@@ -2152,6 +2163,11 @@ class PartitionOpTranslator {
2152
2163
return translateSILPhi (sources);
2153
2164
}
2154
2165
2166
+ case TranslationSemantics::Asserting:
2167
+ llvm::report_fatal_error (
2168
+ " transfer-non-sendable: Found banned instruction?!" );
2169
+ return ;
2170
+
2155
2171
case TranslationSemantics::Unhandled:
2156
2172
LLVM_DEBUG (llvm::dbgs () << " Unhandled inst: " << *inst);
2157
2173
return ;
@@ -2449,18 +2465,9 @@ CONSTANT_TRANSLATION(DeallocStackRefInst, Unhandled)
2449
2465
CONSTANT_TRANSLATION(DeallocRefInst, Unhandled)
2450
2466
CONSTANT_TRANSLATION(DeallocPartialRefInst, Unhandled)
2451
2467
CONSTANT_TRANSLATION(DeallocExistentialBoxInst, Unhandled)
2452
- CONSTANT_TRANSLATION(StrongRetainInst, Unhandled)
2453
- CONSTANT_TRANSLATION(StrongReleaseInst, Unhandled)
2454
2468
CONSTANT_TRANSLATION(UnmanagedRetainValueInst, Unhandled)
2455
2469
CONSTANT_TRANSLATION(UnmanagedReleaseValueInst, Unhandled)
2456
2470
CONSTANT_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)
2464
2471
CONSTANT_TRANSLATION(AutoreleaseValueInst, Unhandled)
2465
2472
CONSTANT_TRANSLATION(FixLifetimeInst, Unhandled)
2466
2473
CONSTANT_TRANSLATION(BeginUnpairedAccessInst, Unhandled)
@@ -2491,6 +2498,18 @@ CONSTANT_TRANSLATION(CondBranchInst, TerminatorPhi)
2491
2498
CONSTANT_TRANSLATION(CheckedCastBranchInst, TerminatorPhi)
2492
2499
CONSTANT_TRANSLATION(DynamicMethodBranchInst, TerminatorPhi)
2493
2500
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
+
2494
2513
#undef CONSTANT_TRANSLATION
2495
2514
2496
2515
#ifdef LOOKTHROUGH_IF_NONSENDABLE_RESULT_REQUIRE_OTHERWISE
@@ -3293,6 +3312,11 @@ class TransferNonSendable : public SILFunctionTransform {
3293
3312
return ;
3294
3313
}
3295
3314
3315
+ if (!function->hasOwnership ()) {
3316
+ LLVM_DEBUG (llvm::dbgs () << " Only runs on Ownership SSA, skipping!\n " );
3317
+ return ;
3318
+ }
3319
+
3296
3320
// The sendable protocol should /always/ be available if TransferNonSendable
3297
3321
// is enabled. If not, there is a major bug in the compiler and we should
3298
3322
// fail loudly.
0 commit comments