Skip to content

Commit

Permalink
Revert "effects: taint nonoverlayed when bailing out inference (#48838
Browse files Browse the repository at this point in the history
)"

This reverts commit 09757f7.
  • Loading branch information
KristofferC committed Mar 10, 2023
1 parent fdbba71 commit a82477b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
4 changes: 3 additions & 1 deletion base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
if seen napplicable
# there is unanalyzed candidate, widen type and effects to the top
rettype = Any
all_effects = Effects()
# there may be unanalyzed effects within unseen dispatch candidate,
# but we can still ignore nonoverlayed effect here since we already accounted for it
all_effects = merge_effects(all_effects, EFFECTS_UNKNOWN)
elseif isa(matches, MethodMatches) ? (!matches.fullmatch || any_ambig(matches)) :
(!all(matches.fullmatches) || any_ambig(matches))
# Account for the fact that we may encounter a MethodError with a non-covered or ambiguous signature.
Expand Down
23 changes: 0 additions & 23 deletions test/compiler/AbstractInterpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ import Base.Experimental: @MethodTable, @overlay
@MethodTable(OverlayedMT)
CC.method_table(interp::MTOverlayInterp) = CC.OverlayMethodTable(CC.get_world_counter(interp), OverlayedMT)

function CC.add_remark!(interp::MTOverlayInterp, ::CC.InferenceState, remark)
if interp.meta !== nothing
# Core.println(remark)
push!(interp.meta, remark)
end
return nothing
end

strangesin(x) = sin(x)
@overlay OverlayedMT strangesin(x::Float64) = iszero(x) ? nothing : cos(x)

Expand All @@ -74,21 +66,6 @@ end |> !Core.Compiler.is_nonoverlayed
@invoke strangesin(x::Float64)
end |> !Core.Compiler.is_nonoverlayed

# account for overlay possibility in unanalyzed matching method
callstrange(::Nothing) = Core.compilerbarrier(:type, nothing) # trigger inference bail out
callstrange(::Float64) = strangesin(x)
callstrange_entry(x) = callstrange(x) # needs to be defined here because of world age
let interp = MTOverlayInterp(; meta=Set{Any}())
matches = Core.Compiler.findall(Tuple{typeof(callstrange),Any}, Core.Compiler.method_table(interp)).matches
@test Core.Compiler.length(matches) == 2
if Core.Compiler.getindex(matches, 1).method == which(callstrange, (Nothing,))
@test Base.infer_effects(callstrange_entry, (Any,); interp) |> !Core.Compiler.is_nonoverlayed
@test "Call inference reached maximally imprecise information. Bailing on." in interp.meta
else
@warn "`nonoverlayed` test for inference bailing out is skipped since the method match sort order is changed."
end
end

# but it should never apply for the native compilation
@test Base.infer_effects((Float64,)) do x
strangesin(x)
Expand Down

0 comments on commit a82477b

Please sign in to comment.