diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index bb68ef117649ea..930e28029a7ce0 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -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} @@ -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, diff --git a/base/compiler/stmtinfo.jl b/base/compiler/stmtinfo.jl index 03458644d76da0..84de4fb1c91f58 100644 --- a/base/compiler/stmtinfo.jl +++ b/base/compiler/stmtinfo.jl @@ -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 diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index bbec2451608541..fdafb3a9634ada 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -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)) diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index 4ae11ca24259a8..6fc8a3b7225996 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -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) @@ -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))