Skip to content

Commit 41fdbc1

Browse files
committed
[ShrinkBorrowScope] Adopt BackwardReachability.
Replaced ShrinkBorrowScope's own data flow with the general BackwardReachability. Took this opportunity to refactor and document the utility. Taken together these changes make ShrinkBorrowScope serve as a template for a future LexicalDestroyHoisting which will operate on owned lexical values (rather than guaranteed as here) and hoist destroy_values (rather than end_borrows as here) but should otherwise be quite similar.
1 parent 94ef0af commit 41fdbc1

File tree

4 files changed

+487
-239
lines changed

4 files changed

+487
-239
lines changed

include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class CanonicalizeBorrowScope {
148148
};
149149

150150
bool shrinkBorrowScope(
151-
BeginBorrowInst *bbi, InstructionDeleter &deleter,
151+
BeginBorrowInst const &bbi, InstructionDeleter &deleter,
152152
SmallVectorImpl<CopyValueInst *> &modifiedCopyValueInsts);
153153

154154
bool foldDestroysOfCopiedLexicalBorrow(BeginBorrowInst *bbi,

lib/SILOptimizer/Transforms/CopyPropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ void CopyPropagation::run() {
451451
// at least once and then until each stops making changes.
452452
while (true) {
453453
SmallVector<CopyValueInst *, 4> modifiedCopyValueInsts;
454-
auto shrunk = shrinkBorrowScope(bbi, deleter, modifiedCopyValueInsts);
454+
auto shrunk = shrinkBorrowScope(*bbi, deleter, modifiedCopyValueInsts);
455455
for (auto *cvi : modifiedCopyValueInsts)
456456
defWorklist.updateForCopy(cvi);
457457
changed |= shrunk;

0 commit comments

Comments
 (0)