We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 127f2f5 commit 960cbcbCopy full SHA for 960cbcb
lib/SILOptimizer/Utils/CanonicalizeInstruction.cpp
@@ -450,6 +450,11 @@ static SILBasicBlock::iterator
450
eliminateSimpleBorrows(BeginBorrowInst *bbi, CanonicalizeInstruction &pass) {
451
auto next = std::next(bbi->getIterator());
452
453
+ // Never eliminate lexical borrow scopes. They must be kept to ensure that
454
+ // value lifetimes aren't observably shortened.
455
+ if (bbi->isLexical())
456
+ return next;
457
+
458
// We know that our borrow is completely within the lifetime of its base value
459
// if the borrow is never reborrowed. We check for reborrows and do not
460
// optimize such cases. Otherwise, we can eliminate our borrow and instead use
0 commit comments