Skip to content

Commit

Permalink
inlining: allow non-compileable result when handling ConcreteResult (
Browse files Browse the repository at this point in the history
…#49074)

* inlining: allow non-compileable result when handling `ConcreteResult`

In rare cases, the system might decide to widen the signature of a call
that is determined to throw by concrete-evaluation.
We should remove this unnecessary assertion here.

closes #49050

* Update test/compiler/inline.jl

Co-authored-by: Jameson Nash <vtjnash@gmail.com>

---------

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
  • Loading branch information
aviatesk and vtjnash authored Mar 21, 2023
1 parent 4d8c22f commit 5b49c03
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ end

function handle_concrete_result!(cases::Vector{InliningCase}, result::ConcreteResult, @nospecialize(info::CallInfo), state::InliningState)
case = concrete_result_item(result, info, state)
case === nothing && return false
push!(cases, InliningCase(result.mi.specTypes, case))
return true
end
Expand All @@ -1505,10 +1506,8 @@ function concrete_result_item(result::ConcreteResult, @nospecialize(info::CallIn
invokesig::Union{Nothing,Vector{Any}}=nothing)
if !may_inline_concrete_result(result)
et = InliningEdgeTracker(state.et, invokesig)
case = compileable_specialization(result.mi, result.effects, et, info;
return compileable_specialization(result.mi, result.effects, et, info;
compilesig_invokes=OptimizationParams(state.interp).compilesig_invokes)
@assert case !== nothing "concrete evaluation should never happen for uncompileable callsite"
return case
end
@assert result.effects === EFFECTS_TOTAL
return ConstantCase(quoted(result.result))
Expand Down
19 changes: 19 additions & 0 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1921,3 +1921,22 @@ let res = @test_throws MethodError let
err = res.value
@test err.f === convert && err.args === (Union{Bool,Tuple{String,String}}, g48397)
end

# https://github.com/JuliaLang/julia/issues/49050
abstract type Issue49050AbsTop{T,N} end
abstract type Issue49050Abs1{T, N} <: Issue49050AbsTop{T,N} end
abstract type Issue49050Abs2{T} <: Issue49050Abs1{T,3} end
struct Issue49050Concrete{T} <: Issue49050Abs2{T}
x::T
end
issue49074(::Type{Issue49050AbsTop{T,N}}) where {T,N} = Issue49050AbsTop{T,N}
Base.@assume_effects :foldable issue49074(::Type{C}) where {C<:Issue49050AbsTop} = issue49074(supertype(C))
let src = code_typed1() do
issue49074(Issue49050Concrete)
end
@test any(isinvoke(:issue49074), src.code)
end
let result = @test_throws MethodError issue49074(Issue49050Concrete)
@test result.value.f === issue49074
@test result.value.args === (Any,)
end

0 comments on commit 5b49c03

Please sign in to comment.