Skip to content

Commit

Permalink
inference: enable :call inference in irinterp
Browse files Browse the repository at this point in the history
Built on top of #48913, this commit enables `:call` inference in irinterp.
In a case when some regression is detected, we can simply revert this
commit rather than reverting the whole refactoring from #48913.
  • Loading branch information
aviatesk committed Apr 28, 2023
1 parent f11bfc6 commit e891443
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
7 changes: 0 additions & 7 deletions base/compiler/ssair/irinterp.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

# TODO (#48913) remove this overload to enable interprocedural call inference from irinterp
function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
arginfo::ArgInfo, si::StmtInfo, @nospecialize(atype),
sv::IRInterpretationState, max_methods::Int)
return CallMeta(Any, Effects(), NoCallInfo())
end

function collect_limitations!(@nospecialize(typ), ::IRInterpretationState)
@assert !isa(typ, LimitedAccuracy) "irinterp is unable to handle heavy recursion"
return typ
Expand Down
49 changes: 24 additions & 25 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4784,31 +4784,30 @@ fhasmethod(::Integer, ::Int32) = 3
@test only(Base.return_types(()) do; Val(hasmethod(sin, Tuple{Int, Vararg{Int}})); end) == Val{false}
@test only(Base.return_types(()) do; Val(hasmethod(sin, Tuple{Int, Int, Vararg{Int}})); end) === Val{false}

# TODO (#48913) enable interprocedural call inference from irinterp
# # interprocedural call inference from irinterp
# @noinline Base.@assume_effects :total issue48679_unknown_any(x) = Base.inferencebarrier(x)

# @noinline _issue48679(y::Union{Nothing,T}) where {T} = T::Type
# Base.@constprop :aggressive function issue48679(x, b)
# if b
# x = issue48679_unknown_any(x)
# end
# return _issue48679(x)
# end
# @test Base.return_types((Float64,)) do x
# issue48679(x, false)
# end |> only == Type{Float64}

# Base.@constprop :aggressive @noinline _issue48679_const(b, y::Union{Nothing,T}) where {T} = b ? nothing : T::Type
# Base.@constprop :aggressive function issue48679_const(x, b)
# if b
# x = issue48679_unknown_any(x)
# end
# return _issue48679_const(b, x)
# end
# @test Base.return_types((Float64,)) do x
# issue48679_const(x, false)
# end |> only == Type{Float64}
# interprocedural call inference from irinterp
@noinline Base.@assume_effects :total issue48679_unknown_any(x) = Base.inferencebarrier(x)

@noinline _issue48679(y::Union{Nothing,T}) where {T} = T::Type
Base.@constprop :aggressive function issue48679(x, b)
if b
x = issue48679_unknown_any(x)
end
return _issue48679(x)
end
@test Base.return_types((Float64,)) do x
issue48679(x, false)
end |> only == Type{Float64}

Base.@constprop :aggressive @noinline _issue48679_const(b, y::Union{Nothing,T}) where {T} = b ? nothing : T::Type
Base.@constprop :aggressive function issue48679_const(x, b)
if b
x = issue48679_unknown_any(x)
end
return _issue48679_const(b, x)
end
@test Base.return_types((Float64,)) do x
issue48679_const(x, false)
end |> only == Type{Float64}

# `invoke` call in irinterp
@noinline _irinterp_invoke(x::Any) = :any
Expand Down

0 comments on commit e891443

Please sign in to comment.