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.
This commit is contained in:
Andrew Trick
2018-02-28 15:43:32 -08:00
parent 33b89122bc
commit 1d08be56a3
2 changed files with 10 additions and 4 deletions

View File

@@ -1142,9 +1142,6 @@ SILInstruction *SILInstruction::clone(SILInstruction *InsertPt) {
/// additional handling. It is important to know this information when
/// you perform such optimizations like e.g. jump-threading.
bool SILInstruction::isTriviallyDuplicatable() const {
if (isa<ThrowInst>(this))
return false;
if (isa<AllocStackInst>(this) || isa<DeallocStackInst>(this)) {
return false;
}
@@ -1152,7 +1149,6 @@ bool SILInstruction::isTriviallyDuplicatable() const {
if (ARI->canAllocOnStack())
return false;
}
if (isa<OpenExistentialAddrInst>(this) || isa<OpenExistentialRefInst>(this) ||
isa<OpenExistentialMetatypeInst>(this) ||
isa<OpenExistentialValueInst>(this) || isa<OpenExistentialBoxInst>(this) ||
@@ -1169,6 +1165,13 @@ bool SILInstruction::isTriviallyDuplicatable() const {
if (MI->getMember().isForeign)
return false;
}
if (isa<ThrowInst>(this))
return false;
// BeginAccess defines the access scope entry point. All associated EndAccess
// instructions must directly operate on the BeginAccess.
if (isa<BeginAccessInst>(this))
return false;
return true;
}