diff --git a/src/CodeInfoTools.jl b/src/CodeInfoTools.jl index 5d54bd4..8e1c346 100644 --- a/src/CodeInfoTools.jl +++ b/src/CodeInfoTools.jl @@ -151,8 +151,9 @@ struct Canvas defs::Vector{Tuple{Int, Int}} code::Vector{Any} codelocs::Vector{Int32} + ssaflags::Vector{UInt32} end -Canvas() = Canvas(Tuple{Int, Int}[], [], Int32[]) +Canvas() = Canvas(Tuple{Int, Int}[], [], Int32[], UInt32[]) Base.isempty(canv::Canvas) = Base.isempty(canv.defs) @@ -193,6 +194,7 @@ getindex(c::Canvas, v::Variable) = getindex(c, v.id) function push!(c::Canvas, stmt::Statement) push!(c.code, stmt) push!(c.codelocs, Int32(1)) + push!(c.ssaflags, UInt32(0)) l = length(c.defs) + 1 push!(c.defs, (l, l)) return Variable(length(c.defs)) @@ -201,6 +203,7 @@ end function push!(c::Canvas, node) push!(c.code, Statement(node)) push!(c.codelocs, Int32(1)) + push!(c.ssaflags, UInt32(0)) l = length(c.defs) + 1 push!(c.defs, (l, l)) return Variable(length(c.defs)) @@ -211,6 +214,7 @@ function insert!(c::Canvas, idx::Int, x::Statement) @assert(ind > 0) push!(c.code, x) push!(c.codelocs, Int32(1)) + push!(c.ssaflags, UInt32(0)) for i in 1 : length(c.defs) r, k = c.defs[i] if k > 0 && k >= ind @@ -290,7 +294,7 @@ function renumber(c::Canvas) ind = first.(s) swap = walk(k -> _get(d, k, k), c.code, Val(:catch_jumps)) return Canvas(Tuple{Int, Int}[(i, i) for i in 1 : length(s)], - getindex(swap, ind), getindex(c.codelocs, ind)) + getindex(swap, ind), getindex(c.codelocs, ind), getindex(c.ssaflags, ind)) end ##### @@ -512,6 +516,7 @@ function finish(b::Builder; validate = true) c = renumber(b.to) new_ci.code = map(unwrap, c.code) new_ci.codelocs = c.codelocs + new_ci.ssaflags = c.ssaflags new_ci.slotnames = copy(b.from.slotnames) append!(new_ci.slotnames, b.slots) new_ci.slotflags = copy(b.from.slotflags) diff --git a/test/canvas.jl b/test/canvas.jl index 4a4f7d8..f8e2c3f 100644 --- a/test/canvas.jl +++ b/test/canvas.jl @@ -13,6 +13,7 @@ for i in 1 : 5 @test c.defs[i] == (i, i) @test c.codelocs[i] == Int32(1) + @test c.ssaflags[i] == UInt32(0) @test unwrap(getindex(c, i)) == Expr(:call, rand) end end