Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/cleanup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ function inline_consts!(ir::IR)
isused(x) = get(us, x, 0) > 0
for v in reverse(keys(ir))
st = ir[v]
effect = effectful(exprtype.((ir,), ir[v].expr.args)...)
if typeof(st.expr) == IRTools.Inner.Variable
effect = true
else
effect = effectful(exprtype.((ir,), ir[v].expr.args)...)
end
if st.type isa Union{Const,Node} && !effect
map(v -> v isa Variable && (us[v] -= 1), st.expr.args)
if st.type isa Node || istrivial(st.type.value) || !isused(v)
Expand Down
12 changes: 12 additions & 0 deletions src/infer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,18 @@ function step!(inf::Inference)
end
elseif isexpr(st.expr, :inbounds)
push!(inf.queue, (frame, b, f, ip+1))
elseif typeof(st.expr) == IRTools.Inner.Variable
if (i = findfirst(x -> x == st.expr, arguments(block))) != nothing
T = argtypes(block)[i]
elseif st.expr in stmts
T = block.ir[st.expr].type
else
error("Unrecognised variable $(st.expr)")
end
if T != Union{}
block.ir[var] = stmt(block[var], type = _union(st.type, T))
push!(inf.queue, (frame, b, f, ip+1))
end
else
error("Unrecognised expression $(st.expr)")
end
Expand Down