Skip to content

Commit f346350

Browse files
committed
Stop renumbering statements in inference proper
I don't think there's any good reason to try to delete the statements here. The very next thing we do is to convert to IRCode which drops dead code anyway, so this just seems redundant. In addition, it complicates Cthulhu-like analysis, which now has to track an extra set of statement numbers.
1 parent 82fbf54 commit f346350

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

base/compiler/typeinfer.jl

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,7 @@ function finish(me::InferenceState, interp::AbstractInterpreter)
556556
# annotate fulltree with type information,
557557
# either because we are the outermost code, or we might use this later
558558
doopt = (me.cached || me.parent !== nothing)
559-
changemap = type_annotate!(interp, me, doopt)
560-
recompute_cfg = changemap !== nothing
559+
recompute_cfg = type_annotate!(interp, me, doopt)
561560
if doopt && may_optimize(interp)
562561
me.result.src = OptimizationState(me, OptimizationParams(interp), interp, recompute_cfg)
563562
else
@@ -715,6 +714,7 @@ function type_annotate!(interp::AbstractInterpreter, sv::InferenceState, run_opt
715714
slotflags = src.slotflags
716715
nslots = length(slotflags)
717716
undefs = fill(false, nslots)
717+
any_unreachable = false
718718

719719
# this statement traversal does five things:
720720
# 1. introduce temporary `TypedSlot`s that are supposed to be replaced with π-nodes later
@@ -742,13 +742,9 @@ function type_annotate!(interp::AbstractInterpreter, sv::InferenceState, run_opt
742742
body[i] = annotate_slot_load!(undefs, i, sv, expr) # 1&2
743743
ssavaluetypes[i] = widenslotwrapper(ssavaluetypes[i]) # 4
744744
else # i.e. any runtime execution will never reach this statement
745+
any_unreachable = true
745746
if is_meta_expr(expr) # keep any lexically scoped expressions
746747
ssavaluetypes[i] = Any # 4
747-
elseif run_optimizer
748-
if changemap === nothing
749-
changemap = fill(0, nexpr)
750-
end
751-
changemap[i] = -1 # 3&4: mark for the bulk deletion
752748
else
753749
ssavaluetypes[i] = Bottom # 4
754750
body[i] = Const(expr) # annotate that this statement actually is dead
@@ -763,19 +759,7 @@ function type_annotate!(interp::AbstractInterpreter, sv::InferenceState, run_opt
763759
end
764760
end
765761

766-
# do the bulk deletion of unreached statements
767-
if changemap !== nothing
768-
inds = Int[i for (i,v) in enumerate(changemap) if v == -1]
769-
deleteat!(body, inds)
770-
deleteat!(ssavaluetypes, inds)
771-
deleteat!(codelocs, inds)
772-
deleteat!(stmt_info, inds)
773-
deleteat!(ssaflags, inds)
774-
renumber_ir_elements!(body, changemap)
775-
return changemap
776-
else
777-
return nothing
778-
end
762+
return any_unreachable
779763
end
780764

781765
# at the end, all items in b's cycle

0 commit comments

Comments
 (0)