Skip to content

Commit

Permalink
Introduce improved SROA pass
Browse files Browse the repository at this point in the history
This is a rebased and fixed version of the improved SROA pass from #26778.
There's a decent piece of new infrastructure wrapped up in this: The ability
to insert new nodes during compaction. This is a bit tricky because it requires
tracking which version of the statements buffer a given SSAValue belongs to.
At the moment this is done mostly manually, but I'm hoping to clean that up
in the future. The idea of the new SROA pass is fairly straightforward:
Given a use of an interesting value, it traces through all phi nodes, finding
all leaves, applies whatever transformation to those leaves and then re-inserts
a phi nest corresponding to the phi nest of the original value.
  • Loading branch information
Keno committed May 16, 2018
1 parent 11c803c commit 9100329
Show file tree
Hide file tree
Showing 8 changed files with 909 additions and 208 deletions.
10 changes: 8 additions & 2 deletions base/compiler/ssair/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include("compiler/ssair/passes.jl")
include("compiler/ssair/inlining2.jl")
include("compiler/ssair/verify.jl")
include("compiler/ssair/legacy.jl")
@isdefined(Base) && include("compiler/ssair/show.jl")
#@isdefined(Base) && include("compiler/ssair/show.jl")

function normalize_expr(stmt::Expr)
if stmt.head === :gotoifnot
Expand Down Expand Up @@ -159,14 +159,20 @@ end

function run_passes(ci::CodeInfo, nargs::Int, linetable::Vector{LineInfoNode}, sv::OptimizationState)
ir = just_construct_ssa(ci, copy(ci.code), nargs, linetable)
#@Base.show ("after_construct", ir)
# TODO: Domsorting can produce an updated domtree - no need to recompute here
@timeit "compact 1" ir = compact!(ir)
#@timeit "verify 1" verify_ir(ir)
@timeit "Inlining" ir = ssa_inlining_pass!(ir, linetable, sv)
#@timeit "verify 2" verify_ir(ir)
@timeit "domtree 2" domtree = construct_domtree(ir.cfg)
ir = compact!(ir)
#@Base.show ("before_sroa", ir)
@timeit "SROA" ir = getfield_elim_pass!(ir, domtree)
@timeit "compact 2" ir = compact!(ir)
#@Base.show ir.new_nodes
#@Base.show ("after_sroa", ir)
ir = adce_pass!(ir)
#@Base.show ("after_adce", ir)
@timeit "type lift" ir = type_lift_pass!(ir)
@timeit "compact 3" ir = compact!(ir)
#@Base.show ir
Expand Down
Loading

0 comments on commit 9100329

Please sign in to comment.