Skip to content

Commit b77a3f8

Browse files
committed
Use the updated hasPointerEscape api in DCE
1 parent 64d344a commit b77a3f8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,16 @@ void DCE::markLive() {
281281
}
282282
break;
283283
}
284-
case SILInstructionKind::EndBorrowInst:
284+
case SILInstructionKind::EndBorrowInst: {
285+
auto phi = PhiValue(I.getOperand(0));
286+
// If there is a pointer escape, disable DCE.
287+
if (phi && hasPointerEscape(phi)) {
288+
markInstructionLive(&I);
289+
}
290+
// The instruction is live only if it's operand value is also live
291+
addReverseDependency(I.getOperand(0), &I);
292+
break;
293+
}
285294
case SILInstructionKind::EndLifetimeInst: {
286295
// The instruction is live only if it's operand value is also live
287296
addReverseDependency(I.getOperand(0), &I);
@@ -311,9 +320,8 @@ void DCE::markLive() {
311320
disableBorrowDCE(root);
312321
}
313322
}
314-
// If we have a lexical borrow scope or a pointer escape, disable DCE.
315-
if (borrowInst->isLexical() ||
316-
hasPointerEscape(BorrowedValue(borrowInst))) {
323+
// If we have a lexical borrow scope, disable DCE.
324+
if (borrowInst->isLexical()) {
317325
disableBorrowDCE(borrowInst);
318326
}
319327
break;

0 commit comments

Comments
 (0)