julia
julia copied to clipboard
`CC.populate_def_use_map!` doesn't work as expected.
MWE:
using Test
const CC = Core.Compiler
ir, ret = only(Base.code_ircode((Int, ); optimize_until="compact 1") do x
y = 2*x
return y
end)
tpdum = CC.TwoPhaseDefUseMap(length(ir.stmts));
CC.populate_def_use_map!(tpdum, ir)
@test !isempty(tpdum.data) # fails, tpdum is empty
The problem is the following, as described by @willtebbutt on Slack:
I'm a bit confused by the use of userefs in populate_def_use_map! , see here: https://github.com/JuliaLang/julia/blob/b19a7c1721f623ae085354889b183622537543b0/base/compiler/ssair/irinterp.jl#L290 In particular:
- the argument to
userefs
is anInstruction
, meaning that the relevant flag of the returnedUseRefIterator
will always be set tofalse
.- The relevant flag being
false
means that no iterations of the linked for loop will ever be performed.- Therefore, calling
populate_def_use_map
does not appear to ever modifytpdum
.