[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.
This commit is contained in:
Nate Chandler
2022-02-11 18:47:17 -08:00
parent 94ef0af9ea
commit 41fdbc1285
4 changed files with 498 additions and 250 deletions

View File

@@ -451,7 +451,7 @@ void CopyPropagation::run() {
// at least once and then until each stops making changes.
while (true) {
SmallVector<CopyValueInst *, 4> modifiedCopyValueInsts;
auto shrunk = shrinkBorrowScope(bbi, deleter, modifiedCopyValueInsts);
auto shrunk = shrinkBorrowScope(*bbi, deleter, modifiedCopyValueInsts);
for (auto *cvi : modifiedCopyValueInsts)
defWorklist.updateForCopy(cvi);
changed |= shrunk;