Skip to content

Commit

Permalink
inference: remove some unneeded parameterization
Browse files Browse the repository at this point in the history
This logic is present to avoid asking ill-posed questions after we
discover the dataflow is terminated, similar to how we'd remove the code
after throw or a constant branch.

Refs: JuliaLang#39439 (comment)
  • Loading branch information
vtjnash authored and ElOceanografo committed May 4, 2021
1 parent 660bff4 commit 0d3a6fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 7 additions & 7 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1202,8 +1202,8 @@ function collect_argtypes(interp::AbstractInterpreter, ea::Vector{Any}, vtypes::
argtypes = Vector{Any}(undef, n)
@inbounds for i = 1:n
ai = abstract_eval_value(interp, ea[i], vtypes, sv)
if bail_out_statement(interp, ai, sv)
return Bottom
if ai === Bottom
return nothing
end
argtypes[i] = ai
end
Expand All @@ -1218,7 +1218,7 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
if e.head === :call
ea = e.args
argtypes = collect_argtypes(interp, ea, vtypes, sv)
if argtypes === Bottom
if argtypes === nothing
t = Bottom
else
callinfo = abstract_call(interp, ea, argtypes, sv)
Expand Down Expand Up @@ -1280,7 +1280,7 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
if length(e.args) >= 5
ea = e.args
argtypes = collect_argtypes(interp, ea, vtypes, sv)
if argtypes === Bottom
if argtypes === nothing
t = Bottom
else
t = _opaque_closure_tfunc(argtypes[1], argtypes[2], argtypes[3],
Expand Down Expand Up @@ -1415,7 +1415,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
if condt === Bottom
empty!(frame.pclimitations)
end
if bail_out_local(interp, condt, frame)
if condt === Bottom
break
end
condval = maybe_extract_const_bool(condt)
Expand Down Expand Up @@ -1506,7 +1506,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
else
if hd === :(=)
t = abstract_eval_statement(interp, stmt.args[2], changes, frame)
if bail_out_local(interp, t, frame)
if t === Bottom
break
end
frame.src.ssavaluetypes[pc] = t
Expand All @@ -1523,7 +1523,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
# these do not generate code
else
t = abstract_eval_statement(interp, stmt, changes, frame)
if bail_out_local(interp, t, frame)
if t === Bottom
break
end
if !isempty(frame.ssavalue_uses[pc])
Expand Down
2 changes: 0 additions & 2 deletions base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ method_table(ai::AbstractInterpreter) = InternalMethodTable(get_world_counter(ai
# - inferring non-concrete toplevel call sites
bail_out_call(interp::AbstractInterpreter, @nospecialize(t), sv) = t === Any
bail_out_apply(interp::AbstractInterpreter, @nospecialize(t), sv) = t === Any
bail_out_statement(interp::AbstractInterpreter, @nospecialize(t), sv) = t === Bottom
bail_out_local(interp::AbstractInterpreter, @nospecialize(t), sv) = t === Bottom
function bail_out_toplevel_call(interp::AbstractInterpreter, @nospecialize(sig), sv)
return isa(sv.linfo.def, Module) && !isdispatchtuple(sig)
end

0 comments on commit 0d3a6fa

Please sign in to comment.