Skip to content

Commit

Permalink
fix up test case for unmatched type param inlining
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Nov 9, 2023
1 parent c95cb95 commit eafa1e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
9 changes: 4 additions & 5 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1393,8 +1393,7 @@ function compute_inlining_cases(@nospecialize(info::CallInfo), flag::UInt32, sig
cases = InliningCase[]
argtypes = sig.argtypes
local handled_all_cases::Bool = true
local revisit_idx = nothing
local only_method = nothing
local revisit_idx = local only_method = nothing
local meth::MethodLookupResult
local all_result_count = 0
local joint_effects::Effects = EFFECTS_TOTAL
Expand All @@ -1410,14 +1409,14 @@ function compute_inlining_cases(@nospecialize(info::CallInfo), flag::UInt32, sig
handled_all_cases = false
continue
else
if length(meth) == 1 && only_method !== false
if length(meth) == 1 && only_method !== missing
if only_method === nothing
only_method = meth[1].method
elseif only_method !== meth[1].method
only_method = false
only_method = missing
end
else
only_method = false
only_method = missing
end
end
local split_fully_covered::Bool = false
Expand Down
25 changes: 11 additions & 14 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1675,31 +1675,28 @@ function oc_capture_oc(z)
end
@test fully_eliminated(oc_capture_oc, (Int,))

# inlining with unmatched type parameters
@eval struct OldVal{T}
x::T
(OV::Type{OldVal{T}})() where T = $(Expr(:new, :OV))
end
with_unmatched_typeparam1(x::OldVal{i}) where {i} = i
with_unmatched_typeparam2() = [ Base.donotdelete(OldVal{i}()) for i in 1:10000 ]
function with_unmatched_typeparam3()
@test OldVal{0}() === OldVal{0}.instance
function with_unmatched_typeparam()
f(x::OldVal{i}) where {i} = i
r = 0
for i = 1:10000
r += f(OldVal{i}())
end
return r
end

@testset "Inlining with unmatched type parameters" begin
let src = code_typed1(with_unmatched_typeparam1, (Any,))
@test !any(@nospecialize(x) -> isexpr(x, :call) && length(x.args) == 1, src.code)
end
let src = code_typed1(with_unmatched_typeparam2)
@test !any(@nospecialize(x) -> isexpr(x, :call) && length(x.args) == 1, src.code)
end
let src = code_typed1(with_unmatched_typeparam3)
@test !any(@nospecialize(x) -> isexpr(x, :call) && length(x.args) == 1, src.code)
let src = code_typed1(with_unmatched_typeparam)
found = nothing
for x in src.code
if isexpr(x, :call) && length(x.args) == 1
found = x
break
end
end
@test isnothing(found) || (source=src, statement=found)
end

function twice_sitofp(x::Int, y::Int)
Expand Down

0 comments on commit eafa1e3

Please sign in to comment.