Skip to content

Commit 952c7a5

Browse files
committed
avoid losing type info from TypedSlots when replacing variables
1 parent ec8ac9e commit 952c7a5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

base/inference.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6225,6 +6225,17 @@ function merge_value_ssa!(ctx::AllocOptContext, info, key)
62256225
if defkey.second || defkey.first > ctx.sv.nargs
62266226
add_allocopt_todo(ctx, defkey)
62276227
end
6228+
6229+
# don't replace TypedSlots with SSAValues
6230+
# TODO: introduce extra SSAValue for each differently-typed use.
6231+
if defkey.second
6232+
for use in info.uses
6233+
if isdefined(use, :expr) && use.expr.args[use.exidx] isa TypedSlot
6234+
return false
6235+
end
6236+
end
6237+
end
6238+
62286239
definfo = ctx.infomap[defkey]
62296240
for def in info.defs
62306241
ctx.changes[def.assign] = nothing
@@ -6238,7 +6249,12 @@ function merge_value_ssa!(ctx::AllocOptContext, info, key)
62386249
end
62396250
for use in info.uses
62406251
if isdefined(use, :expr)
6241-
use.expr.args[use.exidx] = replace_v
6252+
this_use = use.expr.args[use.exidx]
6253+
if !defkey.second && this_use isa TypedSlot
6254+
use.expr.args[use.exidx] = TypedSlot(replace_v.id, this_use.typ)
6255+
else
6256+
use.expr.args[use.exidx] = replace_v
6257+
end
62426258
add_use(definfo, use)
62436259
else
62446260
# This variable is never used undef, ignore statement level use

0 commit comments

Comments
 (0)