@@ -126,13 +126,17 @@ struct UseDefChainVisitor
126126 // do not want to treat this as a merge.
127127 if (auto p = Projection (inst)) {
128128 switch (p.getKind ()) {
129+ // Currently if we load and then project_box from a memory location,
130+ // we treat that as a projection. This follows the semantics/notes in
131+ // getAccessProjectionOperand.
132+ case ProjectionKind::Box:
133+ return cast<ProjectBoxInst>(inst)->getOperand ();
129134 case ProjectionKind::Upcast:
130135 case ProjectionKind::RefCast:
131136 case ProjectionKind::BlockStorageCast:
132137 case ProjectionKind::BitwiseCast:
133- case ProjectionKind::TailElems:
134- case ProjectionKind::Box:
135138 case ProjectionKind::Class:
139+ case ProjectionKind::TailElems:
136140 llvm_unreachable (" Shouldn't see this here" );
137141 case ProjectionKind::Index:
138142 // Index is always a merge.
@@ -1289,8 +1293,7 @@ class PartitionOpTranslator {
12891293 continue ;
12901294 }
12911295 if (auto *pbi = dyn_cast<ProjectBoxInst>(val)) {
1292- if (isNonSendableType (
1293- pbi->getType ().getSILBoxFieldType (function))) {
1296+ if (isNonSendableType (pbi->getType ())) {
12941297 auto trackVal = getTrackableValue (val, true );
12951298 (void )trackVal;
12961299 continue ;
@@ -1431,8 +1434,12 @@ class PartitionOpTranslator {
14311434
14321435 if (auto tryApplyInst = dyn_cast<TryApplyInst>(inst)) {
14331436 foundResults.emplace_back (tryApplyInst->getNormalBB ()->getArgument (0 ));
1434- if (tryApplyInst->getErrorBB ()->getNumArguments () > 0 )
1437+ if (tryApplyInst->getErrorBB ()->getNumArguments () > 0 ) {
14351438 foundResults.emplace_back (tryApplyInst->getErrorBB ()->getArgument (0 ));
1439+ }
1440+ for (auto indirectResults : tryApplyInst->getIndirectSILResults ()) {
1441+ foundResults.emplace_back (indirectResults);
1442+ }
14361443 return ;
14371444 }
14381445
@@ -1797,10 +1804,10 @@ class PartitionOpTranslator {
17971804 };
17981805
17991806 if (applySite.hasSelfArgument ()) {
1800- handleSILOperands (applySite.getOperandsWithoutSelf ());
1807+ handleSILOperands (applySite.getOperandsWithoutIndirectResultsOrSelf ());
18011808 handleSILSelf (&applySite.getSelfArgumentOperand ());
18021809 } else {
1803- handleSILOperands (applySite-> getAllOperands ());
1810+ handleSILOperands (applySite. getOperandsWithoutIndirectResults ());
18041811 }
18051812
18061813 // non-sendable results can't be returned from cross-isolation calls without
@@ -2109,6 +2116,7 @@ class PartitionOpTranslator {
21092116 }
21102117
21112118 case TranslationSemantics::Asserting:
2119+ llvm::errs () << " BannedInst: " << *inst;
21122120 llvm::report_fatal_error (
21132121 " transfer-non-sendable: Found banned instruction?!" );
21142122 return ;
@@ -2119,6 +2127,7 @@ class PartitionOpTranslator {
21192127 return ::isNonSendableType (value->getType (), inst->getFunction ());
21202128 }))
21212129 return ;
2130+ llvm::errs () << " BadInst: " << *inst;
21222131 llvm::report_fatal_error (
21232132 " transfer-non-sendable: Found instruction that is not allowed to "
21242133 " have non-Sendable parameters with such parameters?!" );
@@ -2304,7 +2313,6 @@ CONSTANT_TRANSLATION(TupleInst, Assign)
23042313CONSTANT_TRANSLATION(BeginAccessInst, LookThrough)
23052314CONSTANT_TRANSLATION(BeginBorrowInst, LookThrough)
23062315CONSTANT_TRANSLATION(BeginDeallocRefInst, LookThrough)
2307- CONSTANT_TRANSLATION(RefToBridgeObjectInst, LookThrough)
23082316CONSTANT_TRANSLATION(BridgeObjectToRefInst, LookThrough)
23092317CONSTANT_TRANSLATION(CopyValueInst, LookThrough)
23102318CONSTANT_TRANSLATION(ExplicitCopyValueInst, LookThrough)
@@ -2414,6 +2422,8 @@ CONSTANT_TRANSLATION(BeginUnpairedAccessInst, Require)
24142422CONSTANT_TRANSLATION(ValueMetatypeInst, Require)
24152423// Require of the value we extract the metatype from.
24162424CONSTANT_TRANSLATION(ExistentialMetatypeInst, Require)
2425+ // These can take a parameter. If it is non-Sendable, use a require.
2426+ CONSTANT_TRANSLATION(GetAsyncContinuationAddrInst, Require)
24172427
24182428// ===---
24192429// Asserting If Non Sendable Parameter
@@ -2454,7 +2464,6 @@ CONSTANT_TRANSLATION(DynamicMethodBranchInst, TerminatorPhi)
24542464// (UnsafeContinuation and UnsafeThrowingContinuation).
24552465CONSTANT_TRANSLATION(AwaitAsyncContinuationInst, AssertingIfNonSendable)
24562466CONSTANT_TRANSLATION(GetAsyncContinuationInst, AssertingIfNonSendable)
2457- CONSTANT_TRANSLATION(GetAsyncContinuationAddrInst, AssertingIfNonSendable)
24582467CONSTANT_TRANSLATION(ExtractExecutorInst, AssertingIfNonSendable)
24592468
24602469// ===---
@@ -2614,6 +2623,13 @@ CAST_WITH_MAYBE_SENDABLE_NONSENDABLE_OP_AND_RESULT(UncheckedValueCastInst)
26142623// Custom Handling
26152624//
26162625
2626+ TranslationSemantics
2627+ PartitionOpTranslator::visitRefToBridgeObjectInst (RefToBridgeObjectInst *r) {
2628+ translateSILLookThrough (
2629+ SILValue (r), r->getOperand (RefToBridgeObjectInst::ConvertedOperand));
2630+ return TranslationSemantics::Special;
2631+ }
2632+
26172633TranslationSemantics
26182634PartitionOpTranslator::visitPackElementGetInst (PackElementGetInst *r) {
26192635 if (!isNonSendableType (r->getType ()))
0 commit comments