[MemAccessUtils] Look thru nested for guar roots.

Previously, findGuaranteedReferenceRoots always stopped searching when
finding a begin_borrow, because it's not an ownership-forwarding
instruction.  Here, it is conditionally allowed to keep search through
the borrowee of that begin_borrow if it itself is guaranteed.
This commit is contained in:
Nate Chandler
2022-12-08 18:21:15 -08:00
parent 7430c6142f
commit e1cb0b5522
3 changed files with 15 additions and 3 deletions

View File

@@ -292,7 +292,9 @@ void DCE::markLive() {
// Visit the end_borrows of all the borrow scopes that this
// begin_borrow could be borrowing.
SmallVector<SILValue, 4> roots;
findGuaranteedReferenceRoots(borrowInst->getOperand(), roots);
findGuaranteedReferenceRoots(borrowInst->getOperand(),
/*lookThroughNestedBorrows=*/false,
roots);
for (auto root : roots) {
visitTransitiveEndBorrows(root,
[&](EndBorrowInst *endBorrow) {