Skip to content

Commit

Permalink
AbsInt: thread lattice throughout abstract_call_gf_by_type (JuliaLa…
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Nov 14, 2023
1 parent c1f67f8 commit 1a885c4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ call_result_unused(si::StmtInfo) = !si.used
function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
arginfo::ArgInfo, si::StmtInfo, @nospecialize(atype),
sv::AbsIntState, max_methods::Int)
= (ipo_lattice(interp))
𝕃ₚ, 𝕃ᵢ = ipo_lattice(interp), typeinf_lattice(interp)
= (𝕃ₚ)
if !should_infer_this_call(interp, sv)
add_remark!(interp, sv, "Skipped call in throw block")
# At this point we are guaranteed to end up throwing on this path,
Expand All @@ -21,7 +22,7 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
end

argtypes = arginfo.argtypes
matches = find_matching_methods(typeinf_lattice(interp), argtypes, atype, method_table(interp),
matches = find_matching_methods(𝕃ᵢ, argtypes, atype, method_table(interp),
InferenceParams(interp).max_union_splitting, max_methods)
if isa(matches, FailedMethodMatch)
add_remark!(interp, sv, matches.reason)
Expand All @@ -40,7 +41,6 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
fargs = arginfo.fargs
all_effects = EFFECTS_TOTAL

𝕃ₚ = ipo_lattice(interp)
for i in 1:napplicable
match = applicable[i]::MethodMatch
method = match.method
Expand Down Expand Up @@ -131,9 +131,9 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
Any[Bottom for _ in 1:length(argtypes)]
end
for i = 1:length(argtypes)
cnd = conditional_argtype(this_conditional, sig, argtypes, i)
conditionals[1][i] = tmerge(conditionals[1][i], cnd.thentype)
conditionals[2][i] = tmerge(conditionals[2][i], cnd.elsetype)
cnd = conditional_argtype(𝕃ᵢ, this_conditional, sig, argtypes, i)
conditionals[1][i] = tmerge(𝕃ᵢ, conditionals[1][i], cnd.thentype)
conditionals[2][i] = tmerge(𝕃ᵢ, conditionals[2][i], cnd.elsetype)
end
end
if bail_out_call(interp, InferenceLoopState(sig, rettype, all_effects), sv)
Expand Down Expand Up @@ -394,7 +394,7 @@ function from_interconditional(𝕃ᵢ::AbstractLattice, @nospecialize(rt), sv::
new_elsetype = maybecondinfo[2][i]
else
# otherwise compute it on the fly
cnd = conditional_argtype(rt, maybecondinfo, argtypes, i)
cnd = conditional_argtype(𝕃ᵢ, rt, maybecondinfo, argtypes, i)
new_thentype = cnd.thentype
new_elsetype = cnd.elsetype
end
Expand Down Expand Up @@ -440,11 +440,12 @@ function from_interconditional(𝕃ᵢ::AbstractLattice, @nospecialize(rt), sv::
return widenconditional(rt)
end

function conditional_argtype(@nospecialize(rt), @nospecialize(sig), argtypes::Vector{Any}, i::Int)
function conditional_argtype(𝕃ᵢ::AbstractLattice, @nospecialize(rt), @nospecialize(sig),
argtypes::Vector{Any}, i::Int)
if isa(rt, InterConditional) && rt.slot == i
return rt
else
thentype = elsetype = tmeet(widenslotwrapper(argtypes[i]), fieldtype(sig, i))
thentype = elsetype = tmeet(𝕃ᵢ, widenslotwrapper(argtypes[i]), fieldtype(sig, i))
condval = maybe_extract_const_bool(rt)
condval === true && (elsetype = Bottom)
condval === false && (thentype = Bottom)
Expand Down

0 comments on commit 1a885c4

Please sign in to comment.