Skip to content

Commit 9207d2e

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 10e2001 commit 9207d2e

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
@@ -4763,31 +4763,30 @@ fhasmethod(::Integer, ::Int32) = 3
47634763
@test only(Base.return_types(()) do; Val(hasmethod(sin, Tuple{Int, Vararg{Int}})); end) == Val{false}
47644764
@test only(Base.return_types(()) do; Val(hasmethod(sin, Tuple{Int, Int, Vararg{Int}})); end) === Val{false}
47654765

4766-
# TODO (#48913) enable interprocedural call inference from irinterp
4767-
# # interprocedural call inference from irinterp
4768-
# @noinline Base.@assume_effects :total issue48679_unknown_any(x) = Base.inferencebarrier(x)
4769-
4770-
# @noinline _issue48679(y::Union{Nothing,T}) where {T} = T::Type
4771-
# Base.@constprop :aggressive function issue48679(x, b)
4772-
# if b
4773-
# x = issue48679_unknown_any(x)
4774-
# end
4775-
# return _issue48679(x)
4776-
# end
4777-
# @test Base.return_types((Float64,)) do x
4778-
# issue48679(x, false)
4779-
# end |> only == Type{Float64}
4780-
4781-
# Base.@constprop :aggressive @noinline _issue48679_const(b, y::Union{Nothing,T}) where {T} = b ? nothing : T::Type
4782-
# Base.@constprop :aggressive function issue48679_const(x, b)
4783-
# if b
4784-
# x = issue48679_unknown_any(x)
4785-
# end
4786-
# return _issue48679_const(b, x)
4787-
# end
4788-
# @test Base.return_types((Float64,)) do x
4789-
# issue48679_const(x, false)
4790-
# end |> only == Type{Float64}
4766+
# interprocedural call inference from irinterp
4767+
@noinline Base.@assume_effects :total issue48679_unknown_any(x) = Base.inferencebarrier(x)
4768+
4769+
@noinline _issue48679(y::Union{Nothing,T}) where {T} = T::Type
4770+
Base.@constprop :aggressive function issue48679(x, b)
4771+
if b
4772+
x = issue48679_unknown_any(x)
4773+
end
4774+
return _issue48679(x)
4775+
end
4776+
@test Base.return_types((Float64,)) do x
4777+
issue48679(x, false)
4778+
end |> only == Type{Float64}
4779+
4780+
Base.@constprop :aggressive @noinline _issue48679_const(b, y::Union{Nothing,T}) where {T} = b ? nothing : T::Type
4781+
Base.@constprop :aggressive function issue48679_const(x, b)
4782+
if b
4783+
x = issue48679_unknown_any(x)
4784+
end
4785+
return _issue48679_const(b, x)
4786+
end
4787+
@test Base.return_types((Float64,)) do x
4788+
issue48679_const(x, false)
4789+
end |> only == Type{Float64}
47914790

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

0 commit comments

Comments
 (0)