@@ -183,15 +183,12 @@ struct UseDefChainVisitor
183
183
// / values. We assert that all instructions that are CONSTANT_TRANSLATION
184
184
// / LookThrough to make sure they stay in sync.
185
185
static bool isStaticallyLookThroughInst (SILInstruction *inst) {
186
- if (auto cast = SILDynamicCastInst::getAs (inst))
187
- if (cast.isRCIdentityPreserving ())
188
- return true ;
189
-
190
186
switch (inst->getKind ()) {
191
187
default :
192
188
return false ;
193
189
case SILInstructionKind::BeginAccessInst:
194
190
case SILInstructionKind::BeginBorrowInst:
191
+ case SILInstructionKind::BeginCOWMutationInst:
195
192
case SILInstructionKind::BeginDeallocRefInst:
196
193
case SILInstructionKind::BridgeObjectToRefInst:
197
194
case SILInstructionKind::CopyValueInst:
@@ -224,6 +221,13 @@ static bool isStaticallyLookThroughInst(SILInstruction *inst) {
224
221
case SILInstructionKind::UpcastInst:
225
222
case SILInstructionKind::ValueToBridgeObjectInst:
226
223
return true ;
224
+ case SILInstructionKind::UnconditionalCheckedCastInst: {
225
+ auto cast = SILDynamicCastInst::getAs (inst);
226
+ assert (cast);
227
+ if (cast.isRCIdentityPreserving ())
228
+ return true ;
229
+ return false ;
230
+ }
227
231
}
228
232
}
229
233
@@ -2306,6 +2310,7 @@ CONSTANT_TRANSLATION(UnownedToRefInst, LookThrough)
2306
2310
CONSTANT_TRANSLATION(UnownedCopyValueInst, LookThrough)
2307
2311
CONSTANT_TRANSLATION(DropDeinitInst, LookThrough)
2308
2312
CONSTANT_TRANSLATION(ValueToBridgeObjectInst, LookThrough)
2313
+ CONSTANT_TRANSLATION(BeginCOWMutationInst, LookThrough)
2309
2314
2310
2315
// ===---
2311
2316
// Store
@@ -2321,6 +2326,9 @@ CONSTANT_TRANSLATION(StoreInst, Store)
2321
2326
CONSTANT_TRANSLATION(StoreBorrowInst, Store)
2322
2327
CONSTANT_TRANSLATION(StoreWeakInst, Store)
2323
2328
CONSTANT_TRANSLATION(MarkUnresolvedMoveAddrInst, Store)
2329
+ CONSTANT_TRANSLATION(UncheckedRefCastAddrInst, Store)
2330
+ CONSTANT_TRANSLATION(UnconditionalCheckedCastAddrInst, Store)
2331
+ CONSTANT_TRANSLATION(StoreUnownedInst, Store)
2324
2332
2325
2333
// ===---
2326
2334
// Ignored
@@ -2332,8 +2340,13 @@ CONSTANT_TRANSLATION(MarkUnresolvedMoveAddrInst, Store)
2332
2340
CONSTANT_TRANSLATION(AllocGlobalInst, Ignored)
2333
2341
CONSTANT_TRANSLATION(AutoreleaseValueInst, Ignored)
2334
2342
CONSTANT_TRANSLATION(DeallocBoxInst, Ignored)
2343
+ CONSTANT_TRANSLATION(DeallocPartialRefInst, Ignored)
2344
+ CONSTANT_TRANSLATION(DeallocRefInst, Ignored)
2335
2345
CONSTANT_TRANSLATION(DeallocStackInst, Ignored)
2346
+ CONSTANT_TRANSLATION(DeallocStackRefInst, Ignored)
2336
2347
CONSTANT_TRANSLATION(DebugValueInst, Ignored)
2348
+ CONSTANT_TRANSLATION(DeinitExistentialAddrInst, Ignored)
2349
+ CONSTANT_TRANSLATION(DeinitExistentialValueInst, Ignored)
2337
2350
CONSTANT_TRANSLATION(DestroyAddrInst, Ignored)
2338
2351
CONSTANT_TRANSLATION(DestroyValueInst, Ignored)
2339
2352
CONSTANT_TRANSLATION(EndAccessInst, Ignored)
@@ -2346,6 +2359,8 @@ CONSTANT_TRANSLATION(MetatypeInst, Ignored)
2346
2359
CONSTANT_TRANSLATION(EndApplyInst, Ignored)
2347
2360
CONSTANT_TRANSLATION(AbortApplyInst, Ignored)
2348
2361
CONSTANT_TRANSLATION(DebugStepInst, Ignored)
2362
+ CONSTANT_TRANSLATION(IncrementProfilerCounterInst, Ignored)
2363
+ CONSTANT_TRANSLATION(TestSpecificationInst, Ignored)
2349
2364
2350
2365
// ===---
2351
2366
// Require
@@ -2410,7 +2425,6 @@ CONSTANT_TRANSLATION(VectorInst, Unhandled)
2410
2425
CONSTANT_TRANSLATION(TuplePackElementAddrInst, Unhandled)
2411
2426
CONSTANT_TRANSLATION(TuplePackExtractInst, Unhandled)
2412
2427
CONSTANT_TRANSLATION(PackElementGetInst, Unhandled)
2413
- CONSTANT_TRANSLATION(RefTailAddrInst, Unhandled)
2414
2428
CONSTANT_TRANSLATION(InitExistentialValueInst, Unhandled)
2415
2429
CONSTANT_TRANSLATION(InitExistentialMetatypeInst, Unhandled)
2416
2430
CONSTANT_TRANSLATION(OpenExistentialMetatypeInst, Unhandled)
@@ -2433,9 +2447,6 @@ CONSTANT_TRANSLATION(RebindMemoryInst, Unhandled)
2433
2447
CONSTANT_TRANSLATION(ThrowAddrInst, Unhandled)
2434
2448
CONSTANT_TRANSLATION(AwaitAsyncContinuationInst, Unhandled)
2435
2449
CONSTANT_TRANSLATION(DeallocPackInst, Unhandled)
2436
- CONSTANT_TRANSLATION(DeallocStackRefInst, Unhandled)
2437
- CONSTANT_TRANSLATION(DeallocRefInst, Unhandled)
2438
- CONSTANT_TRANSLATION(DeallocPartialRefInst, Unhandled)
2439
2450
CONSTANT_TRANSLATION(UnmanagedRetainValueInst, Unhandled)
2440
2451
CONSTANT_TRANSLATION(UnmanagedReleaseValueInst, Unhandled)
2441
2452
CONSTANT_TRANSLATION(UnmanagedAutoreleaseValueInst, Unhandled)
@@ -2445,15 +2456,7 @@ CONSTANT_TRANSLATION(AssignInst, Unhandled)
2445
2456
CONSTANT_TRANSLATION(AssignByWrapperInst, Unhandled)
2446
2457
CONSTANT_TRANSLATION(AssignOrInitInst, Unhandled)
2447
2458
CONSTANT_TRANSLATION(MarkFunctionEscapeInst, Unhandled)
2448
- CONSTANT_TRANSLATION(TestSpecificationInst, Unhandled)
2449
- CONSTANT_TRANSLATION(StoreUnownedInst, Unhandled)
2450
- CONSTANT_TRANSLATION(DeinitExistentialAddrInst, Unhandled)
2451
- CONSTANT_TRANSLATION(DeinitExistentialValueInst, Unhandled)
2452
- CONSTANT_TRANSLATION(UnconditionalCheckedCastAddrInst, Unhandled)
2453
- CONSTANT_TRANSLATION(UncheckedRefCastAddrInst, Unhandled)
2454
2459
CONSTANT_TRANSLATION(PackElementSetInst, Unhandled)
2455
- CONSTANT_TRANSLATION(IncrementProfilerCounterInst, Unhandled)
2456
- CONSTANT_TRANSLATION(BeginCOWMutationInst, Unhandled)
2457
2460
2458
2461
// ===---
2459
2462
// Apply
@@ -2628,12 +2631,42 @@ TranslationSemantics PartitionOpTranslator::visitUnconditionalCheckedCastInst(
2628
2631
// ref_element_addr to be merged into.
2629
2632
TranslationSemantics
2630
2633
PartitionOpTranslator::visitRefElementAddrInst (RefElementAddrInst *reai) {
2631
- // If we are accessing a let of a Sendable type, do not treat the
2632
- // ref_element_addr as a require use.
2633
- if (reai->getField ()->isLet () && !isNonSendableType (reai->getType ())) {
2634
- LLVM_DEBUG (llvm::dbgs () << " Found a let! Not tracking!\n " );
2635
- return TranslationSemantics::Ignored;
2634
+ // If our field is a NonSendableType...
2635
+ if (!isNonSendableType (reai->getType ())) {
2636
+ // And the field is a let... then ignore it. We know that we cannot race on
2637
+ // any writes to the field.
2638
+ if (reai->getField ()->isLet ()) {
2639
+ LLVM_DEBUG (llvm::dbgs () << " Found a let! Not tracking!\n " );
2640
+ return TranslationSemantics::Ignored;
2641
+ }
2642
+
2643
+ // Otherwise, we need to treat the access to the field as a require since we
2644
+ // could have a race on assignment to the class.
2645
+ return TranslationSemantics::Require;
2636
2646
}
2647
+
2648
+ return TranslationSemantics::Assign;
2649
+ }
2650
+
2651
+ TranslationSemantics
2652
+ PartitionOpTranslator::visitRefTailAddrInst (RefTailAddrInst *reai) {
2653
+ // If our trailing type is Sendable...
2654
+ if (!isNonSendableType (reai->getType ())) {
2655
+ // And our ref_tail_addr is immutable... we can ignore the access since we
2656
+ // cannot race against a write to any of these fields.
2657
+ if (reai->isImmutable ()) {
2658
+ LLVM_DEBUG (
2659
+ llvm::dbgs ()
2660
+ << " Found an immutable Sendable ref_tail_addr! Not tracking!\n " );
2661
+ return TranslationSemantics::Ignored;
2662
+ }
2663
+
2664
+ // Otherwise, we need a require since the value maybe alive.
2665
+ return TranslationSemantics::Require;
2666
+ }
2667
+
2668
+ // If we have a NonSendable type, treat the address as a separate Element from
2669
+ // our base value.
2637
2670
return TranslationSemantics::Assign;
2638
2671
}
2639
2672
0 commit comments