Skip to content

Commit 747b4ca

Browse files
authored
Correct var ssa mapping (#53)
Unlike equations, which have a fairly unambiguous ssa mapping, it's not entirely clear what we should be displaying here. For now, make this display only callee internal variables, which is the obvious thing to do. I think it would also make sense to indicate variables there were originated by a particular callee, but possibly in a different colors, but I'm puting on that for this PR, since it needs additional changes in StateSelection.
1 parent 6d62163 commit 747b4ca

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/transform/tearing/schedule.jl

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ Compiler.get_inference_world(interp::DummyOptInterp) = interp.world
670670

671671
function StateSelection.SSAUses(result::DAEIPOResult)
672672
eq_callees = Union{Nothing, Vector{StructuralSSARef}}[]
673-
var_callees_dict = Dict{Int,Vector{StructuralSSARef}}()
673+
var_callees = Vector{Union{Nothing, Vector{StructuralSSARef}}}(nothing, length(result.varclassification))
674674
for value in result.eq_callee_mapping
675675
if value === nothing
676676
push!(eq_callees, nothing)
@@ -679,7 +679,20 @@ function StateSelection.SSAUses(result::DAEIPOResult)
679679
callee = collect(unique(first.(value)))
680680
push!(eq_callees, callee)
681681
end
682-
var_callees = [get(var_callees_dict, i, nothing) for i in 1:maximum(keys(var_callees_dict); init = 0)]
682+
for i = 1:length(result.ir.stmts)
683+
info = result.ir[SSAValue(i)][:info]
684+
info isa MappingInfo || continue
685+
for (callee_var, caller_mapping) in enumerate(info.mapping.var_coeffs)
686+
isa(caller_mapping, Incidence) || continue
687+
if length(rowvals(caller_mapping.row)) == 1
688+
caller_var = only(rowvals(caller_mapping.row)) - 1
689+
caller_var === 0 && continue
690+
result.varclassification[caller_var] == CalleeInternal || continue
691+
var_callees[caller_var] !== nothing || (var_callees[caller_var] = Vector{StructuralSSARef}())
692+
push!(var_callees[caller_var], StructuralSSARef(i))
693+
end
694+
end
695+
end
683696
return StateSelection.SSAUses(CalleeInfo.(eq_callees), CalleeInfo.(var_callees))
684697
end
685698

0 commit comments

Comments
 (0)