@@ -194,6 +194,7 @@ struct UseDefChainVisitor
194
194
} // namespace
195
195
196
196
static SILValue getUnderlyingTrackedObjectValue (SILValue value) {
197
+ auto *fn = value->getFunction ();
197
198
SILValue result = value;
198
199
while (true ) {
199
200
SILValue temp = result;
@@ -208,6 +209,21 @@ static SILValue getUnderlyingTrackedObjectValue(SILValue value) {
208
209
}
209
210
}
210
211
212
+ if (auto *r = dyn_cast<RefToRawPointerInst>(temp)) {
213
+ // If our operand is a non-Sendable type, look through this instruction.
214
+ if (isNonSendableType (r->getOperand ()->getType (), fn)) {
215
+ temp = r->getOperand ();
216
+ }
217
+ }
218
+
219
+ if (auto *r = dyn_cast<RawPointerToRefInst>(temp)) {
220
+ // If our result is a non-Sendable type, look through this
221
+ // instruction. Builtin.RawPointer is always non-Sendable.
222
+ if (isNonSendableType (r->getType (), fn)) {
223
+ temp = r->getOperand ();
224
+ }
225
+ }
226
+
211
227
if (auto *dsi = dyn_cast_or_null<DestructureStructInst>(
212
228
temp->getDefiningInstruction ())) {
213
229
temp = dsi->getOperand ();
@@ -2321,6 +2337,7 @@ CONSTANT_TRANSLATION(UncheckedAddrCastInst, Assign)
2321
2337
CONSTANT_TRANSLATION(UncheckedEnumDataInst, Assign)
2322
2338
CONSTANT_TRANSLATION(UncheckedOwnershipConversionInst, Assign)
2323
2339
CONSTANT_TRANSLATION(UnmanagedToRefInst, Assign)
2340
+ CONSTANT_TRANSLATION(IndexRawPointerInst, Assign)
2324
2341
2325
2342
// These are used by SIL to aggregate values together in a gep like way. We
2326
2343
// want to look at uses of structs, not the struct uses itself. So just
@@ -2450,12 +2467,9 @@ CONSTANT_TRANSLATION(DeallocExistentialBoxInst, Ignored)
2450
2467
// Unhandled Instructions
2451
2468
//
2452
2469
2453
- CONSTANT_TRANSLATION(IndexRawPointerInst, Unhandled)
2454
2470
CONSTANT_TRANSLATION(UncheckedTrivialBitCastInst, Unhandled)
2455
2471
CONSTANT_TRANSLATION(UncheckedBitwiseCastInst, Unhandled)
2456
2472
CONSTANT_TRANSLATION(UncheckedValueCastInst, Unhandled)
2457
- CONSTANT_TRANSLATION(RefToRawPointerInst, Unhandled)
2458
- CONSTANT_TRANSLATION(RawPointerToRefInst, Unhandled)
2459
2473
CONSTANT_TRANSLATION(RefToUnownedInst, Unhandled)
2460
2474
CONSTANT_TRANSLATION(UnownedToRefInst, Unhandled)
2461
2475
CONSTANT_TRANSLATION(BridgeObjectToWordInst, Unhandled)
@@ -2605,6 +2619,27 @@ IGNORE_IF_SENDABLE_RESULT_ASSIGN_OTHERWISE(StructExtractInst)
2605
2619
// Custom Handling
2606
2620
//
2607
2621
2622
+ TranslationSemantics
2623
+ PartitionOpTranslator::visitRawPointerToRefInst (RawPointerToRefInst *r) {
2624
+ // If our result is non sendable, perform a look through.
2625
+ if (isNonSendableType (r->getType ()))
2626
+ return TranslationSemantics::LookThrough;
2627
+
2628
+ // Otherwise to be conservative, we need to treat this as a require.
2629
+ return TranslationSemantics::Require;
2630
+ }
2631
+
2632
+ TranslationSemantics
2633
+ PartitionOpTranslator::visitRefToRawPointerInst (RefToRawPointerInst *r) {
2634
+ // If our source ref is non sendable, perform a look through.
2635
+ if (isNonSendableType (r->getOperand ()->getType ()))
2636
+ return TranslationSemantics::LookThrough;
2637
+
2638
+ // Otherwise to be conservative, we need to treat the raw pointer as a fresh
2639
+ // sendable value.
2640
+ return TranslationSemantics::AssignFresh;
2641
+ }
2642
+
2608
2643
TranslationSemantics
2609
2644
PartitionOpTranslator::visitMarkDependenceInst (MarkDependenceInst *mdi) {
2610
2645
translateSILAssign (mdi, mdi->getValue ());
0 commit comments