From 3b993a958900d7f3b1aa064f2bf9e917edae0f79 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Thu, 27 Apr 2023 09:00:57 +0900 Subject: [PATCH] AbstractInterpreter: account for overlay possibility in unanalyzed call (#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` --- base/compiler/abstractinterpretation.jl | 15 +-------------- test/compiler/AbstractInterpreter.jl | 1 + 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index e817e0bd927fe..451cbed407c35 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -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 diff --git a/test/compiler/AbstractInterpreter.jl b/test/compiler/AbstractInterpreter.jl index ffd7117cd99be..2a2502a003ac5 100644 --- a/test/compiler/AbstractInterpreter.jl +++ b/test/compiler/AbstractInterpreter.jl @@ -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