@@ -310,6 +310,8 @@ static bool isStaticallyLookThroughInst(SILInstruction *inst) {
310
310
case SILInstructionKind::UnmanagedToRefInst:
311
311
case SILInstructionKind::InitExistentialValueInst:
312
312
case SILInstructionKind::UncheckedEnumDataInst:
313
+ case SILInstructionKind::StructElementAddrInst:
314
+ case SILInstructionKind::TupleElementAddrInst:
313
315
return true ;
314
316
case SILInstructionKind::MoveValueInst:
315
317
// Look through if it isn't from a var decl.
@@ -334,9 +336,6 @@ static bool isLookThroughIfOperandAndResultNonSendable(SILInstruction *inst) {
334
336
case SILInstructionKind::UncheckedTrivialBitCastInst:
335
337
case SILInstructionKind::UncheckedBitwiseCastInst:
336
338
case SILInstructionKind::UncheckedValueCastInst:
337
- case SILInstructionKind::StructElementAddrInst:
338
- case SILInstructionKind::TupleElementAddrInst:
339
- case SILInstructionKind::UncheckedTakeEnumDataAddrInst:
340
339
case SILInstructionKind::ConvertEscapeToNoEscapeInst:
341
340
case SILInstructionKind::ConvertFunctionInst:
342
341
case SILInstructionKind::RefToRawPointerInst:
@@ -735,6 +734,7 @@ TrackableValueLookupResult RegionAnalysisValueMap::getTrackableValue(
735
734
736
735
auto trackedValue =
737
736
getTrackableValueHelper (value, isAddressCapturedByPartialApply);
737
+
738
738
std::optional<TrackableValue> trackedBase;
739
739
if (base)
740
740
trackedBase =
@@ -1130,6 +1130,17 @@ void TrackableValueLookupResult::print(llvm::raw_ostream &os) const {
1130
1130
}
1131
1131
}
1132
1132
1133
+ // ===----------------------------------------------------------------------===//
1134
+ // MARK: UnderlyingTrackedValueInfo
1135
+ // ===----------------------------------------------------------------------===//
1136
+
1137
+ void RegionAnalysisValueMap::UnderlyingTrackedValueInfo::print (
1138
+ llvm::raw_ostream &os) const {
1139
+ os << " RegionAnalysisValueMap.\n Value: " << value;
1140
+ if (base)
1141
+ os << " Base: " << base;
1142
+ }
1143
+
1133
1144
// ===----------------------------------------------------------------------===//
1134
1145
// MARK: Partial Apply Reachability
1135
1146
// ===----------------------------------------------------------------------===//
@@ -3204,10 +3215,16 @@ void PartitionOpBuilder::addRequire(TrackableValueLookupResult value) {
3204
3215
if (!boxType->getLayout ()->isMutable ())
3205
3216
return ;
3206
3217
3218
+ options |= PartitionOp::Flag::RequireOfMutableBaseOfSendableValue;
3219
+ } else if (auto *asi = dyn_cast<AllocStackInst>(rep)) {
3220
+ if (asi->isLet ())
3221
+ return ;
3222
+
3207
3223
options |= PartitionOp::Flag::RequireOfMutableBaseOfSendableValue;
3208
3224
}
3225
+
3226
+ addRequire (value.base , options);
3209
3227
}
3210
- addRequire (value.base , options);
3211
3228
}
3212
3229
}
3213
3230
@@ -3355,6 +3372,9 @@ CONSTANT_TRANSLATION(RefToUnmanagedInst, LookThrough)
3355
3372
CONSTANT_TRANSLATION(UnmanagedToRefInst, LookThrough)
3356
3373
CONSTANT_TRANSLATION(InitExistentialValueInst, LookThrough)
3357
3374
CONSTANT_TRANSLATION(UncheckedEnumDataInst, LookThrough)
3375
+ CONSTANT_TRANSLATION(TupleElementAddrInst, LookThrough)
3376
+ CONSTANT_TRANSLATION(StructElementAddrInst, LookThrough)
3377
+ CONSTANT_TRANSLATION(UncheckedTakeEnumDataAddrInst, LookThrough)
3358
3378
3359
3379
// ===---
3360
3380
// Store
@@ -3604,9 +3624,6 @@ IGNORE_IF_SENDABLE_RESULT_ASSIGN_OTHERWISE(StructExtractInst)
3604
3624
LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND (UncheckedTrivialBitCastInst)
3605
3625
LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND(UncheckedBitwiseCastInst)
3606
3626
LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND(UncheckedValueCastInst)
3607
- LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND(TupleElementAddrInst)
3608
- LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND(StructElementAddrInst)
3609
- LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND(UncheckedTakeEnumDataAddrInst)
3610
3627
LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND(ConvertEscapeToNoEscapeInst)
3611
3628
LOOKTHROUGH_IF_NONSENDABLE_RESULT_AND_OPERAND(ConvertFunctionInst)
3612
3629
@@ -3701,20 +3718,42 @@ PartitionOpTranslator::visitBeginBorrowInst(BeginBorrowInst *bbi) {
3701
3718
return TranslationSemantics::LookThrough;
3702
3719
}
3703
3720
3704
- // / LoadInst is technically a statically look through instruction, but we want
3705
- // / to handle it especially in the infrastructure, so we cannot mark it as
3706
- // / such. This makes marking it as a normal lookthrough instruction impossible
3707
- // / since the routine checks that invariant.
3708
- TranslationSemantics PartitionOpTranslator::visitLoadInst (LoadInst *limvi) {
3721
+ // / LoadInst has two different semantics:
3722
+ // /
3723
+ // / 1. If the load produces a non-Sendable value, we want to treat it as a
3724
+ // / statically look through instruction, but we want to handle it especially in
3725
+ // / the infrastructure, so we cannot mark it as such. This makes marking it as a
3726
+ // / normal lookthrough instruction impossible since the routine checks that
3727
+ // / invariant.
3728
+ // /
3729
+ // / 2. If the load produces a Sendable value, we want to perform a require on
3730
+ // / the address so that if we have a load from a non-Sendable base, we properly
3731
+ // / require the base.
3732
+ TranslationSemantics PartitionOpTranslator::visitLoadInst (LoadInst *li) {
3733
+ if (SILIsolationInfo::isSendableType (li->getOperand ())) {
3734
+ translateSILRequire (li->getOperand ());
3735
+ }
3736
+
3709
3737
return TranslationSemantics::Special;
3710
3738
}
3711
3739
3712
- // / LoadBorrowInst is technically a statically look through instruction, but we
3713
- // / want to handle it especially in the infrastructure, so we cannot mark it as
3714
- // / such. This makes marking it as a normal lookthrough instruction impossible
3715
- // / since the routine checks that invariant.
3740
+ // / LoadBorrowInst has two different semantics:
3741
+ // /
3742
+ // / 1. If the load produces a non-Sendable value, we want to treat it as a
3743
+ // / statically look through instruction, but we want to handle it especially in
3744
+ // / the infrastructure, so we cannot mark it as such. This makes marking it as a
3745
+ // / normal lookthrough instruction impossible since the routine checks that
3746
+ // / invariant.
3747
+ // /
3748
+ // / 2. If the load produces a Sendable value, we want to perform a require on
3749
+ // / the address so that if we have a load from a non-Sendable base, we properly
3750
+ // / require the base.
3716
3751
TranslationSemantics
3717
3752
PartitionOpTranslator::visitLoadBorrowInst (LoadBorrowInst *lbi) {
3753
+ if (SILIsolationInfo::isSendableType (lbi->getOperand ())) {
3754
+ translateSILRequire (lbi->getOperand ());
3755
+ }
3756
+
3718
3757
return TranslationSemantics::Special;
3719
3758
}
3720
3759
0 commit comments