@@ -641,7 +641,7 @@ its argument).
641
641
In a case when all usages are fully eliminated, `struct` allocation may also be erased as
642
642
a result of succeeding dead code elimination.
643
643
"""
644
- function sroa_pass! (ir:: IRCode )
644
+ function sroa_pass! (ir:: IRCode , nargs :: Int )
645
645
compact = IncrementalCompact (ir)
646
646
defuses = nothing # will be initialized once we encounter mutability in order to reduce dynamic allocations
647
647
lifting_cache = IdDict {Pair{AnySSAValue, Any}, AnySSAValue} ()
@@ -813,17 +813,18 @@ function sroa_pass!(ir::IRCode)
813
813
used_ssas = copy (compact. used_ssas)
814
814
simple_dce! (compact, (x:: SSAValue ) -> used_ssas[x. id] -= 1 )
815
815
ir = complete (compact)
816
- sroa_mutables! (ir, defuses, used_ssas)
816
+ sroa_mutables! (ir, defuses, used_ssas, nargs )
817
817
return ir
818
818
else
819
819
simple_dce! (compact)
820
820
return complete (compact)
821
821
end
822
822
end
823
823
824
- function sroa_mutables! (ir:: IRCode , defuses:: IdDict{Int, Tuple{SPCSet, SSADefUse}} , used_ssas:: Vector{Int} )
824
+ function sroa_mutables! (ir:: IRCode , defuses:: IdDict{Int, Tuple{SPCSet, SSADefUse}} , used_ssas:: Vector{Int} , nargs :: Int )
825
825
# initialization of domtree is delayed to avoid the expensive computation in many cases
826
826
local domtree = nothing
827
+ estate = analyze_escapes (ir, nargs)
827
828
for (idx, (intermediaries, defuse)) in defuses
828
829
intermediaries = collect (intermediaries)
829
830
# Check if there are any uses we did not account for. If so, the variable
@@ -899,6 +900,7 @@ function sroa_mutables!(ir::IRCode, defuses::IdDict{Int, Tuple{SPCSet, SSADefUse
899
900
end
900
901
end
901
902
end
903
+ is_sroa_eligible (estate[SSAValue (idx)]) || println (" [EA] bad EA: " , ir. argtypes[1 : nargs], " at " , idx)
902
904
# Everything accounted for. Go field by field and perform idf:
903
905
# Compute domtree now, needed below, now that we have finished compacting the IR.
904
906
# This needs to be after we iterate through the IR with `IncrementalCompact`
0 commit comments