Skip to content

Commit a135f4f

Browse files
committed
Check lexicality at reborrow instead of borrow while disabling DCE
1 parent b77a3f8 commit a135f4f

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ void DCE::markLive() {
283283
}
284284
case SILInstructionKind::EndBorrowInst: {
285285
auto phi = PhiValue(I.getOperand(0));
286-
// If there is a pointer escape, disable DCE.
287-
if (phi && hasPointerEscape(phi)) {
286+
// If there is a pointer escape or phi is lexical, disable DCE.
287+
if (phi && (hasPointerEscape(phi) || phi->isLexical())) {
288288
markInstructionLive(&I);
289289
}
290290
// The instruction is live only if it's operand value is also live
@@ -320,10 +320,6 @@ void DCE::markLive() {
320320
disableBorrowDCE(root);
321321
}
322322
}
323-
// If we have a lexical borrow scope, disable DCE.
324-
if (borrowInst->isLexical()) {
325-
disableBorrowDCE(borrowInst);
326-
}
327323
break;
328324
}
329325
case SILInstructionKind::LoadBorrowInst: {

0 commit comments

Comments
 (0)