Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ function compileable_specialization(mi::MethodInstance, effects::Effects,
# If this caller does not want us to optimize calls to use their
# declared compilesig, then it is also likely they would handle sparams
# incorrectly if there were any unknown typevars, so we conservatively return nothing
if _any(t->isa(t, TypeVar), match.sparams)
if any(@nospecialize(t)->isa(t, TypeVar), mi.sparam_vals)
return nothing
end
end
Expand Down
47 changes: 46 additions & 1 deletion test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ using Test
using Base.Meta
using Core: ReturnNode

include(normpath(@__DIR__, "irutils.jl"))
include("irutils.jl")
include("newinterp.jl")

"""
Helper to walk the AST and call a function on every node.
Expand Down Expand Up @@ -1990,3 +1991,47 @@ for run_finalizer_escape_test in (run_finalizer_escape_test1, run_finalizer_esca
@test finalizer_escape == 3
end
end

# `compilesig_invokes` inlining option
@newinterp NoCompileSigInvokes
Core.Compiler.OptimizationParams(::NoCompileSigInvokes) =
Core.Compiler.OptimizationParams(; compilesig_invokes=false)
@noinline no_compile_sig_invokes(@nospecialize x) = (x !== Any && !Base.has_free_typevars(x))
# test the single dispatch candidate case
let src = code_typed1((Type,)) do x
no_compile_sig_invokes(x)
end
@test count(src.code) do @nospecialize x
isinvoke(:no_compile_sig_invokes, x) &&
(x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),Any}
end == 1
end
let src = code_typed1((Type,); interp=NoCompileSigInvokes()) do x
no_compile_sig_invokes(x)
end
@test count(src.code) do @nospecialize x
isinvoke(:no_compile_sig_invokes, x) &&
(x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),Type}
end == 1
end
# test the union split case
let src = code_typed1((Union{DataType,UnionAll},)) do x
no_compile_sig_invokes(x)
end
@test count(src.code) do @nospecialize x
isinvoke(:no_compile_sig_invokes, x) &&
(x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),Any}
end == 2
end
let src = code_typed1((Union{DataType,UnionAll},); interp=NoCompileSigInvokes()) do x
no_compile_sig_invokes(x)
end
@test count(src.code) do @nospecialize x
isinvoke(:no_compile_sig_invokes, x) &&
(x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),DataType}
end == 1
@test count(src.code) do @nospecialize x
isinvoke(:no_compile_sig_invokes, x) &&
(x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),UnionAll}
end == 1
end