Skip to content

Commit 500e985

Browse files
committed
inference: enable :call inference in irinterp
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.
1 parent 827d34a commit 500e985

File tree

2 files changed

+24
-32
lines changed

2 files changed

+24
-32
lines changed

base/compiler/ssair/irinterp.jl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
# TODO (#48913) remove this overload to enable interprocedural call inference from irinterp
4-
function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
5-
arginfo::ArgInfo, si::StmtInfo, @nospecialize(atype),
6-
sv::IRInterpretationState, max_methods::Int)
7-
return CallMeta(Any, Effects(), NoCallInfo())
8-
end
9-
103
function collect_limitations!(@nospecialize(typ), ::IRInterpretationState)
114
@assert !isa(typ, LimitedAccuracy) "irinterp is unable to handle heavy recursion"
125
return typ

test/compiler/inference.jl

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4784,31 +4784,30 @@ fhasmethod(::Integer, ::Int32) = 3
47844784
@test only(Base.return_types(()) do; Val(hasmethod(sin, Tuple{Int, Vararg{Int}})); end) == Val{false}
47854785
@test only(Base.return_types(()) do; Val(hasmethod(sin, Tuple{Int, Int, Vararg{Int}})); end) === Val{false}
47864786

4787-
# TODO (#48913) enable interprocedural call inference from irinterp
4788-
# # interprocedural call inference from irinterp
4789-
# @noinline Base.@assume_effects :total issue48679_unknown_any(x) = Base.inferencebarrier(x)
4790-
4791-
# @noinline _issue48679(y::Union{Nothing,T}) where {T} = T::Type
4792-
# Base.@constprop :aggressive function issue48679(x, b)
4793-
# if b
4794-
# x = issue48679_unknown_any(x)
4795-
# end
4796-
# return _issue48679(x)
4797-
# end
4798-
# @test Base.return_types((Float64,)) do x
4799-
# issue48679(x, false)
4800-
# end |> only == Type{Float64}
4801-
4802-
# Base.@constprop :aggressive @noinline _issue48679_const(b, y::Union{Nothing,T}) where {T} = b ? nothing : T::Type
4803-
# Base.@constprop :aggressive function issue48679_const(x, b)
4804-
# if b
4805-
# x = issue48679_unknown_any(x)
4806-
# end
4807-
# return _issue48679_const(b, x)
4808-
# end
4809-
# @test Base.return_types((Float64,)) do x
4810-
# issue48679_const(x, false)
4811-
# end |> only == Type{Float64}
4787+
# interprocedural call inference from irinterp
4788+
@noinline Base.@assume_effects :total issue48679_unknown_any(x) = Base.inferencebarrier(x)
4789+
4790+
@noinline _issue48679(y::Union{Nothing,T}) where {T} = T::Type
4791+
Base.@constprop :aggressive function issue48679(x, b)
4792+
if b
4793+
x = issue48679_unknown_any(x)
4794+
end
4795+
return _issue48679(x)
4796+
end
4797+
@test Base.return_types((Float64,)) do x
4798+
issue48679(x, false)
4799+
end |> only == Type{Float64}
4800+
4801+
Base.@constprop :aggressive @noinline _issue48679_const(b, y::Union{Nothing,T}) where {T} = b ? nothing : T::Type
4802+
Base.@constprop :aggressive function issue48679_const(x, b)
4803+
if b
4804+
x = issue48679_unknown_any(x)
4805+
end
4806+
return _issue48679_const(b, x)
4807+
end
4808+
@test Base.return_types((Float64,)) do x
4809+
issue48679_const(x, false)
4810+
end |> only == Type{Float64}
48124811

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

0 commit comments

Comments
 (0)