Skip to content

Commit 1d08be5

Browse files
committed
Mark begin_access is non-clonable (!isTriviallyDuplicatable()).
In one shot, this prevents multiple CFG transforms from breaking the simple begin/end access marker pattern for access scopes.
1 parent 33b8912 commit 1d08be5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/SIL/LoopInfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ bool SILLoop::canDuplicate(SILInstruction *I) const {
8181
if (isa<ThrowInst>(I))
8282
return false;
8383

84+
if (isa<BeginAccessInst>(I))
85+
return false;
86+
8487
assert(I->isTriviallyDuplicatable() &&
8588
"Code here must match isTriviallyDuplicatable in SILInstruction");
8689
return true;

lib/SIL/SILInstruction.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,17 +1142,13 @@ SILInstruction *SILInstruction::clone(SILInstruction *InsertPt) {
11421142
/// additional handling. It is important to know this information when
11431143
/// you perform such optimizations like e.g. jump-threading.
11441144
bool SILInstruction::isTriviallyDuplicatable() const {
1145-
if (isa<ThrowInst>(this))
1146-
return false;
1147-
11481145
if (isa<AllocStackInst>(this) || isa<DeallocStackInst>(this)) {
11491146
return false;
11501147
}
11511148
if (auto *ARI = dyn_cast<AllocRefInst>(this)) {
11521149
if (ARI->canAllocOnStack())
11531150
return false;
11541151
}
1155-
11561152
if (isa<OpenExistentialAddrInst>(this) || isa<OpenExistentialRefInst>(this) ||
11571153
isa<OpenExistentialMetatypeInst>(this) ||
11581154
isa<OpenExistentialValueInst>(this) || isa<OpenExistentialBoxInst>(this) ||
@@ -1169,6 +1165,13 @@ bool SILInstruction::isTriviallyDuplicatable() const {
11691165
if (MI->getMember().isForeign)
11701166
return false;
11711167
}
1168+
if (isa<ThrowInst>(this))
1169+
return false;
1170+
1171+
// BeginAccess defines the access scope entry point. All associated EndAccess
1172+
// instructions must directly operate on the BeginAccess.
1173+
if (isa<BeginAccessInst>(this))
1174+
return false;
11721175

11731176
return true;
11741177
}

0 commit comments

Comments
 (0)