Skip to content

Commit

Permalink
avoid losing type info from TypedSlots when replacing variables
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Dec 2, 2017
1 parent 4a9d7d9 commit 292f959
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6078,6 +6078,17 @@ function merge_value_ssa!(ctx::AllocOptContext, info, key)
if defkey.second || defkey.first > ctx.sv.nargs
add_allocopt_todo(ctx, defkey)
end

# don't replace TypedSlots with SSAValues
# TODO: introduce extra SSAValue for each differently-typed use.
if defkey.second
for use in info.uses
if isdefined(use, :expr) && use.expr.args[use.exidx] isa TypedSlot
return false
end
end
end

definfo = ctx.infomap[defkey]
for def in info.defs
ctx.changes[def.assign] = nothing
Expand All @@ -6091,7 +6102,12 @@ function merge_value_ssa!(ctx::AllocOptContext, info, key)
end
for use in info.uses
if isdefined(use, :expr)
use.expr.args[use.exidx] = replace_v
this_use = use.expr.args[use.exidx]
if !defkey.second && this_use isa TypedSlot
use.expr.args[use.exidx] = TypedSlot(replace_v.id, this_use.typ)
else
use.expr.args[use.exidx] = replace_v
end
add_use(definfo, use)
else
# This variable is never used undef, ignore statement level use
Expand Down

0 comments on commit 292f959

Please sign in to comment.