Skip to content

Commit c8a2130

Browse files
committed
Add a SSADestroyHoisting utility and pass
Extract and rewrite the destroy hoisting algorithm originally from CopyForwarding (in 2014). This is now a light-weight utility for hoisting destroy_addr instructions. Shrinking an object's memory lifetime can allow removal of copy_addr and other optimization. This is extremely low-overhead and can run at any optimization level without dependency on any analysis. This algorithm is: - Incremental - SSA-based - Canonical - Free from alias analysis See file-level comments. The immediate purpose is to specify and test the constraints introduced by adding lexical variable lifetimes to SIL semantics. It can be used as a template for end_borrow hoisting. Ultimately, this utility can be invoked within any pass that needs to optimize a particular uniquely identified address. It will be used to remove much of the complexity from CopyForwarding.
1 parent 3e532b2 commit c8a2130

File tree

4 files changed

+751
-0
lines changed

4 files changed

+751
-0
lines changed

include/swift/SILOptimizer/PassManager/Passes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ PASS(DefiniteInitialization, "definite-init",
194194
"Definite Initialization for Diagnostics")
195195
PASS(DestroyHoisting, "destroy-hoisting",
196196
"Hoisting of value destroys")
197+
PASS(SSADestroyHoisting, "ssa-destroy-hoisting",
198+
"Hoist destroy_addr for uniquely identified values")
197199
PASS(Devirtualizer, "devirtualizer",
198200
"Indirect Call Devirtualization")
199201
PASS(DiagnoseInfiniteRecursion, "diagnose-infinite-recursion",

lib/SILOptimizer/Transforms/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ target_sources(swiftSILOptimizer PRIVATE
3535
SILLowerAggregateInstrs.cpp
3636
SILMem2Reg.cpp
3737
SILSROA.cpp
38+
SSADestroyHoisting.cpp
3839
SimplifyCFG.cpp
3940
Sink.cpp
4041
SpeculativeDevirtualizer.cpp

0 commit comments

Comments
 (0)