[CanonicalizeBorrowScope] Look through moves.

When encountering inside a borrow scope a non-lexical move_value or a
move_value [lexical] where the borrowed value is itself already lexical,
delete the move_value and regard its uses as uses of the moved-from
value.
This commit is contained in:
Nate Chandler
2023-01-18 17:24:30 -08:00
parent 11b76da7fa
commit 10e86d6653
5 changed files with 117 additions and 24 deletions

View File

@@ -78,9 +78,9 @@
using namespace swift;
using llvm::SmallSetVector;
llvm::Statistic swift::NumCopiesEliminated = {
DEBUG_TYPE, "NumCopiesEliminated",
"number of copy_value instructions removed"};
llvm::Statistic swift::NumCopiesAndMovesEliminated = {
DEBUG_TYPE, "NumCopiesAndMovesEliminated",
"number of copy_value and move_value instructions removed"};
llvm::Statistic swift::NumCopiesGenerated = {
DEBUG_TYPE, "NumCopiesGenerated",
@@ -970,7 +970,7 @@ void CanonicalizeOSSALifetime::rewriteCopies() {
} else {
if (instsToDelete.insert(srcCopy)) {
LLVM_DEBUG(llvm::dbgs() << " Removing " << *srcCopy);
++NumCopiesEliminated;
++NumCopiesAndMovesEliminated;
}
}
}