Skip to content

Commit

Permalink
AbstractInterpreter: account for overlay possibility in unanalyzed ca…
Browse files Browse the repository at this point in the history
…ll (#49518)

When we skip inference of a call on `throw` block, previously we only
checked if the call is overlayed or not. But the call may call an
overlayed method internally, thus we need to conservatively taint the
`:nonoverlayed` bit when `interp` uses overlay method table.

Nevertheless this will not introduce any regressions on GPUCompiler
stack (like #48097), since it defines `InferenceParams(::GPUInterpreter)`
overload to turn off `unoptimize_throw_blocks`
<https://github.com/JuliaGPU/GPUCompiler.jl/blob/d5086fb3d93bbc4795a96f6f1457898af46a24cb/src/interface.jl#L272>
  • Loading branch information
aviatesk authored Apr 27, 2023
1 parent 5c39e44 commit 3b993a9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
15 changes: 1 addition & 14 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,10 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
= (ipo_lattice(interp))
if !should_infer_this_call(interp, sv)
add_remark!(interp, sv, "Skipped call in throw block")
nonoverlayed = false
if isoverlayed(method_table(interp)) && is_nonoverlayed(sv.ipo_effects)
# as we may want to concrete-evaluate this frame in cases when there are
# no overlayed calls, try an additional effort now to check if this call
# isn't overlayed rather than just handling it conservatively
matches = find_matching_methods(typeinf_lattice(interp), arginfo.argtypes, atype, method_table(interp),
InferenceParams(interp).max_union_splitting, max_methods)
if !isa(matches, FailedMethodMatch)
nonoverlayed = matches.nonoverlayed
end
else
nonoverlayed = true
end
# At this point we are guaranteed to end up throwing on this path,
# which is all that's required for :consistent-cy. Of course, we don't
# know anything else about this statement.
effects = Effects(; consistent=ALWAYS_TRUE, nonoverlayed)
effects = Effects(; consistent=ALWAYS_TRUE, nonoverlayed=!isoverlayed(method_table(interp)))
return CallMeta(Any, effects, NoCallInfo())
end

Expand Down
1 change: 1 addition & 0 deletions test/compiler/AbstractInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ end |> only === Nothing
@newinterp Issue48097Interp
@MethodTable Issue48097MT
CC.method_table(interp::Issue48097Interp) = CC.OverlayMethodTable(CC.get_world_counter(interp), Issue48097MT)
CC.InferenceParams(::Issue48097Interp) = CC.InferenceParams(; unoptimize_throw_blocks=false)
@overlay Issue48097MT @noinline Core.throw_inexacterror(f::Symbol, ::Type{T}, val) where {T} = return
issue48097(; kwargs...) = return 42
@test fully_eliminated(; interp=Issue48097Interp(), retval=42) do
Expand Down

0 comments on commit 3b993a9

Please sign in to comment.