Check lexicality at reborrow instead of borrow while disabling DCE

This commit is contained in:
Meghana Gupta
2023-03-28 16:52:06 -07:00
parent b77a3f8a38
commit a135f4fc50

View File

@@ -283,8 +283,8 @@ void DCE::markLive() {
}
case SILInstructionKind::EndBorrowInst: {
auto phi = PhiValue(I.getOperand(0));
// If there is a pointer escape, disable DCE.
if (phi && hasPointerEscape(phi)) {
// If there is a pointer escape or phi is lexical, disable DCE.
if (phi && (hasPointerEscape(phi) || phi->isLexical())) {
markInstructionLive(&I);
}
// The instruction is live only if it's operand value is also live
@@ -320,10 +320,6 @@ void DCE::markLive() {
disableBorrowDCE(root);
}
}
// If we have a lexical borrow scope, disable DCE.
if (borrowInst->isLexical()) {
disableBorrowDCE(borrowInst);
}
break;
}
case SILInstructionKind::LoadBorrowInst: {