Skip to content

Commit 9b0075c

Browse files
committed
compiler: remove dead code
- inlining.jl: `UnionSplitSignature` (and its `SimpleCartesian` helper) is no longer used - abstractinterpretation.jl: the use of `precise_container_type` seems to be introduced in #26826, but I think `getfield_tfunc` at this moment is precise enough to propagate elements of constant tuples.
1 parent 5a98032 commit 9b0075c

File tree

2 files changed

+1
-55
lines changed

2 files changed

+1
-55
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,16 +1086,7 @@ function abstract_call_builtin(interp::AbstractInterpreter, f::Builtin, fargs::U
10861086
end
10871087
end
10881088
rt = builtin_tfunction(interp, f, argtypes[2:end], sv)
1089-
if f === getfield && isa(fargs, Vector{Any}) && la == 3 &&
1090-
(a3 = argtypes[3]; isa(a3, Const)) && (idx = a3.val; isa(idx, Int)) &&
1091-
(a2 = argtypes[2]; a2 Tuple)
1092-
# TODO: why doesn't this use the getfield_tfunc?
1093-
cti_info = precise_container_type(interp, iterate, a2, sv)
1094-
cti = cti_info[1]::Vector{Any}
1095-
if 1 <= idx <= length(cti)
1096-
rt = unwrapva(cti[idx])
1097-
end
1098-
elseif (rt === Bool || (isa(rt, Const) && isa(rt.val, Bool))) && isa(fargs, Vector{Any})
1089+
if (rt === Bool || (isa(rt, Const) && isa(rt.val, Bool))) && isa(fargs, Vector{Any})
10991090
# perform very limited back-propagation of type information for `is` and `isa`
11001091
if f === isa
11011092
a = ssa_def_slot(fargs[2], sv)

base/compiler/ssair/inlining.jl

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -842,51 +842,6 @@ function InliningTodo(mi::MethodInstance, src::Union{CodeInfo, Array{UInt8, 1}})
842842
end
843843
end
844844

845-
# Neither the product iterator not CartesianIndices are available
846-
# here, so use this poor man's version
847-
struct SimpleCartesian
848-
ranges::Vector{UnitRange{Int}}
849-
end
850-
function iterate(s::SimpleCartesian, state::Vector{Int}=Int[1 for _ in 1:length(s.ranges)])
851-
state[end] > last(s.ranges[end]) && return nothing
852-
vals = copy(state)
853-
any = false
854-
for i = 1:length(s.ranges)
855-
if state[i] < last(s.ranges[i])
856-
for j = 1:(i-1)
857-
state[j] = first(s.ranges[j])
858-
end
859-
state[i] += 1
860-
any = true
861-
break
862-
end
863-
end
864-
if !any
865-
state[end] += 1
866-
end
867-
(vals, state)
868-
end
869-
870-
# Given a signure, iterate over the signatures to union split over
871-
struct UnionSplitSignature
872-
it::SimpleCartesian
873-
typs::Vector{Any}
874-
end
875-
876-
function UnionSplitSignature(atypes::Vector{Any})
877-
typs = Any[uniontypes(widenconst(atypes[i])) for i = 1:length(atypes)]
878-
ranges = UnitRange{Int}[1:length(typs[i]) for i = 1:length(typs)]
879-
return UnionSplitSignature(SimpleCartesian(ranges), typs)
880-
end
881-
882-
function iterate(split::UnionSplitSignature, state::Vector{Int}...)
883-
y = iterate(split.it, state...)
884-
y === nothing && return nothing
885-
idxs, state = y
886-
sig = Any[split.typs[i][j] for (i, j) in enumerate(idxs)]
887-
return (sig, state)
888-
end
889-
890845
function handle_single_case!(ir::IRCode, stmt::Expr, idx::Int, @nospecialize(case), isinvoke::Bool, todo::Vector{Pair{Int, Any}})
891846
if isa(case, ConstantCase)
892847
ir[SSAValue(idx)] = case.val

0 commit comments

Comments
 (0)