Skip to content

Commit 3648bf6

Browse files
committed
[region-isolation] Rely on our classification of lookthrough or not to find underlying tracked object values rather than delegating to other analysis helpers.
There is no guarantee that these other helpers properly model lookthrough as our model does. This ensures that this routine is always in sync with how we define lookthrough in our model. The problem with the old approach can be seen in how we handled move_value. The model and the later code knew correctly that they should not look through move_value that is marked as [var_decl]. But this other analysis code did not. This with the tree today should not have any impact. But with the fix I am doing now (fixing nonisolated(unsafe)) and later isolation history this will become a problem. (cherry picked from commit b66cfcc)
1 parent 0478883 commit 3648bf6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/SILOptimizer/Analysis/RegionAnalysis.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,16 @@ struct UseDefChainVisitor
128128
cast->getFunction()))
129129
return SILValue();
130130

131+
// Do not look through begin_borrow [var_decl]. They are start new semantic
132+
// values.
133+
//
134+
// This only comes up if a codegen pattern occurs where the debug
135+
// information is place on a debug_value instead of the alloc_box.
136+
if (auto *bbi = dyn_cast<BeginBorrowInst>(cast)) {
137+
if (bbi->isFromVarDecl())
138+
return SILValue();
139+
}
140+
131141
// If we do not have an identity cast, mark this as a merge.
132142
isMerge |= castType != AccessStorageCast::Identity;
133143

@@ -305,11 +315,6 @@ static SILValue getUnderlyingTrackedObjectValue(SILValue value) {
305315
while (true) {
306316
SILValue temp = result;
307317

308-
temp = stripSinglePredecessorArgs(temp);
309-
temp = stripAddressProjections(temp);
310-
temp = stripIndexingInsts(temp);
311-
temp = lookThroughOwnershipInsts(temp);
312-
313318
if (auto *svi = dyn_cast<SingleValueInstruction>(temp)) {
314319
if (isStaticallyLookThroughInst(svi)) {
315320
temp = svi->getOperand(0);
@@ -356,6 +361,11 @@ static SILValue getUnderlyingTrackedObjectValue(SILValue value) {
356361
}
357362

358363
static UnderlyingTrackedValueInfo getUnderlyingTrackedValue(SILValue value) {
364+
// Look through a project_box, so that we process it like its operand object.
365+
if (auto *pbi = dyn_cast<ProjectBoxInst>(value)) {
366+
value = pbi->getOperand();
367+
}
368+
359369
if (!value->getType().isAddress()) {
360370
SILValue underlyingValue = getUnderlyingTrackedObjectValue(value);
361371

0 commit comments

Comments
 (0)