Skip to content

Commit a1bcf17

Browse files
committed
Avoid optimizing lexical borrow scopes in DCE
1 parent 6c0c3dd commit a1bcf17

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/SILOptimizer/Transforms/DeadCodeElimination.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,10 @@ void DCE::markLive() {
303303
}
304304
// Populate reborrowDependencies for this borrow
305305
findReborrowDependencies(borrowInst);
306-
if (hasPointerEscape(BorrowedValue(borrowInst))) {
306+
// Don't optimize a borrow scope if it is lexical or has a pointer
307+
// escape.
308+
if (borrowInst->isLexical() ||
309+
hasPointerEscape(BorrowedValue(borrowInst))) {
307310
// Visit all end_borrows and mark them live
308311
visitTransitiveEndBorrows(borrowInst, [&](EndBorrowInst *endBorrow) {
309312
markInstructionLive(endBorrow);

0 commit comments

Comments
 (0)