Skip to content

Commit 313f0e2

Browse files
committed
[CopyPropagation] Added lexical destroy folding.
The new utility folds patterns like TOP: // %borrowee is some owned value %lifetime = begin_borrow %borrowee BOTTOM: // %copy is some transitive copy of %borrowee apply %f(%copy) end_borrow %lifetime destroy_value %borrowee into TOP: %move = move_value [lexical] %borrowee %lifetime begin_borrow [lexical] %move BOTTOM: end_borrow %lifetime apply %f(%move) It is intended to be run after ShrinkBorrowScope moves the end_borrow up to just before a relevant apply and after CanonicalizeOSSALifetime moves destroy_value instructions up to just after their last guaranteed use, at which point these patterns will exist.
1 parent 5c1a172 commit 313f0e2

File tree

5 files changed

+1618
-2
lines changed

5 files changed

+1618
-2
lines changed

include/swift/SILOptimizer/Utils/CanonicalizeBorrowScope.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ bool shrinkBorrowScope(
151151
BeginBorrowInst *bbi, InstructionDeleter &deleter,
152152
SmallVectorImpl<CopyValueInst *> &modifiedCopyValueInsts);
153153

154+
bool foldDestroysOfCopiedLexicalBorrow(BeginBorrowInst *bbi,
155+
DominanceInfo &dominanceTree,
156+
InstructionDeleter &deleter);
157+
154158
} // namespace swift
155159

156160
#endif // SWIFT_SILOPTIMIZER_UTILS_CANONICALIZEBORROWSCOPES_H

lib/SILOptimizer/Utils/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ target_sources(swiftSILOptimizer PRIVATE
1818
InstructionDeleter.cpp
1919
InstOptUtils.cpp
2020
KeyPathProjector.cpp
21+
LexicalDestroyFolding.cpp
2122
LoadStoreOptUtils.cpp
2223
LoopUtils.cpp
2324
OptimizerStatsUtils.cpp

0 commit comments

Comments
 (0)