Skip to content

Commit

Permalink
inference: relax backedge optimization condition
Browse files Browse the repository at this point in the history
Follows up #45017.
We can relax the condition in `add_call_backedges!` for backedge optimization
by ignoring the `nonoverlayed` property when the `AbstractInterpreter`
doesn't use overlayed method table at all, since the property will never
be tainted anyway even if we add a new method later.
  • Loading branch information
aviatesk committed Apr 20, 2022
1 parent ab11173 commit 8debd02
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,18 @@ function add_call_backedges!(interp::AbstractInterpreter,
@nospecialize(rettype), all_effects::Effects,
edges::Vector{MethodInstance}, matches::Union{MethodMatches,UnionSplitMethodMatches}, @nospecialize(atype),
sv::InferenceState)
if rettype === Any && all_effects === Effects()
# for `NativeInterpreter`, we don't need to add backedges when:
# - a new method couldn't refine (widen) this type and
# - the effects don't provide any useful information for interprocedural optimization
return
# we don't need to add backedges when:
# - a new method couldn't refine (widen) this type and
# - the effects are known to not provide any useful IPO information
if rettype === Any
if !isoverlayed(method_table(interp))
# we can ignore the `nonoverlayed` property if `interp` doesn't use
# overlayed method table at all since it will never be tainted anyway
all_effects = Effects(all_effects; nonoverlayed=false)
end
if all_effects === Effects()
return
end
end
for edge in edges
add_backedge!(edge, sv)
Expand Down

0 comments on commit 8debd02

Please sign in to comment.