Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Sep 24, 2024
1 parent 0e0350b commit a7aae3c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
24 changes: 0 additions & 24 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,6 @@ any_ambig(info::MethodMatchInfo) = any_ambig(info.results)
any_ambig(m::MethodMatches) = any_ambig(m.info)
fully_covering(info::MethodMatchInfo) = info.fullmatch
fully_covering(m::MethodMatches) = fully_covering(m.info)
function add_uncovered_edges!(sv::AbsIntState, info::MethodMatchInfo, @nospecialize(atype))
fully_covering(info) || add_mt_backedge!(sv, info.mt, atype)
nothing
end
add_uncovered_edges!(sv::AbsIntState, matches::MethodMatches, @nospecialize(atype)) =
add_uncovered_edges!(sv, matches.info, atype)

struct UnionSplitMethodMatches
applicable::Vector{Any}
Expand All @@ -292,24 +286,6 @@ any_ambig(info::UnionSplitInfo) = any(any_ambig, info.split)
any_ambig(m::UnionSplitMethodMatches) = any_ambig(m.info)
fully_covering(info::UnionSplitInfo) = all(fully_covering, info.split)
fully_covering(m::UnionSplitMethodMatches) = fully_covering(m.info)
function add_uncovered_edges!(sv::AbsIntState, info::UnionSplitInfo, @nospecialize(atype))
all(fully_covering, info.split) && return nothing
# add mt backedges with removing duplications
for mt in uncovered_method_tables(info)
add_mt_backedge!(sv, mt, atype)
end
end
add_uncovered_edges!(sv::AbsIntState, matches::UnionSplitMethodMatches, @nospecialize(atype)) =
add_uncovered_edges!(sv, matches.info, atype)
function uncovered_method_tables(info::UnionSplitInfo)
mts = MethodTable[]
for mminfo in info.split
fully_covering(mminfo) && continue
any(mt′::MethodTable->mt′===mminfo.mt, mts) && continue
push!(mts, mminfo.mt)
end
return mts
end

function find_method_matches(interp::AbstractInterpreter, argtypes::Vector{Any}, @nospecialize(atype);
max_union_splitting::Int = InferenceParams(interp).max_union_splitting,
Expand Down
9 changes: 9 additions & 0 deletions base/compiler/stmtinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ function add_uncovered_edges_impl(edges::Vector{Any}, info::UnionSplitInfo, @nos
push!(edges, mt, atype)
end
end
function uncovered_method_tables(info::UnionSplitInfo)
mts = MethodTable[]
for mminfo in info.split
fully_covering(mminfo) && continue
any(mt′::MethodTable->mt′===mminfo.mt, mts) && continue
push!(mts, mminfo.mt)
end
return mts
end

abstract type ConstResult end

Expand Down
5 changes: 4 additions & 1 deletion base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3024,7 +3024,10 @@ function _hasmethod_tfunc(interp::AbstractInterpreter, argtypes::Vector{Any}, sv
update_valid_age!(sv, valid_worlds)
if match === nothing
rt = Const(false)
add_edges!(sv.edges, MethodMatchInfo(MethodLookupResult(Any[], valid_worlds, true), types, mt)) # XXX: this should actually be an invoke-type backedge
let vresults = MethodLookupResult(Any[], valid_worlds, true)
vinfo = MethodMatchInfo(vresults, mt, types, false)
add_edges!(sv.edges, vinfo) # XXX: this should actually be an invoke-type backedge
end
else
rt = Const(true)
add_edges!(sv.edges, InvokeCallInfo(match, nothing, types))
Expand Down
12 changes: 7 additions & 5 deletions base/compiler/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,15 @@ function add_edges!(edges::Vector{Any}, info::ApplyCallInfo)
end
end
add_edges!(edges::Vector{Any}, info::ModifyOpInfo) = add_edges!(edges, info.info)
add_edges!(edges::Vector{Any}, info::UnionSplitInfo) = for split in info.matches; add_edges!(edges, split); end
add_edges!(edges::Vector{Any}, info::UnionSplitApplyCallInfo) = for split in info.infos; add_edges!(edges, split); end
add_edges!(edges::Vector{Any}, info::UnionSplitInfo) =
for split in info.split; add_edges!(edges, split); end
add_edges!(edges::Vector{Any}, info::UnionSplitApplyCallInfo) =
for split in info.infos; add_edges!(edges, split); end
add_edges!(edges::Vector{Any}, info::FinalizerInfo) = nothing # merely allocating a finalizer does not imply edges (unless it gets inlined later)
add_edges!(edges::Vector{Any}, info::NoCallInfo) = nothing
function add_edges!(edges::Vector{Any}, info::MethodMatchInfo)
matches = info.results.matches
if isempty(matches) || !(matches[end]::Core.MethodMatch).fully_covers
if !fully_covering(info)
# add legacy-style missing backedge info also
exists = false
for i in 1:length(edges)
Expand All @@ -690,13 +692,13 @@ function add_edges!(edges::Vector{Any}, info::MethodMatchInfo)
mi = specialize_method(m)
if mi.specTypes === m.spec_types
add_one_edge!(edges, mi)
return
return nothing
end
end
# add check for whether this lookup already existed in the edges list
for i in 1:length(edges)
if edges[i] === length(matches) && edges[i + 1] == info.atype
return
return nothing
end
end
push!(edges, length(matches))
Expand Down

0 comments on commit a7aae3c

Please sign in to comment.