Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
14 changes: 13 additions & 1 deletion Compiler/src/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,20 @@ end
function handle_invoke_call!(todo::Vector{Pair{Int,Any}},
ir::IRCode, idx::Int, stmt::Expr, @nospecialize(info), flag::UInt32,
sig::Signature, state::InliningState)
# InvokeCICallInfo indicates that `abstract_invoke` already analyzed the call
# and determined it is of the form `invoke(f, ::CodeInstance, args...)`
# where the argtypes and worldages are valid for the context, and the invoke
# pointer is set. Therefore, we can simply transform this into an
# `Expr(:invoke, ...)`
if info isa InvokeCICallInfo
stmt.head = :invoke
stmt.args = [info.edge, stmt.args[2], stmt.args[4:end]...]
# Transformed to :invoke, now handle it as such
handle_invoke_expr!(todo, ir, idx, stmt, info, flag, sig, state)
return nothing
end
nspl = nsplit(info)
nspl == 0 && return nothing # e.g. InvokeCICallInfo
nspl == 0 && return nothing
@assert nspl == 1
mresult = getsplit(info, 1)
match = mresult.matches[1]
Expand Down
15 changes: 15 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8557,6 +8557,21 @@ f_invalidate_me() = 2
@test_throws ErrorException invoke(f_invoke_me, f_invoke_me_ci)
@test_throws ErrorException f_call_me()

mysin(x::Float64) = sin(x)
@test mysin(1.0) == sin(1.0)
const mysin_ci = Base.specialize_method(Base._which(Tuple{typeof(mysin), Float64})).cache
mysin2(x::Float64) = invoke(mysin, mysin_ci, x)
@test mysin2(1.0) == sin(1.0)
@test any(1:3) do _
@allocated(mysin2(rand())) == 0
end
let this_world = Base.get_world_counter()
f(x) = invoke(mysin, mysin_ci, x)
@atomic mysin_ci.min_world = this_world + 10
@test_throws ErrorException f(1.0)
end


myfun57023a(::Type{T}) where {T} = (x = @ccall mycfun()::Ptr{T}; x)
@test only(code_lowered(myfun57023a)).has_fcall
myfun57023b(::Type{T}) where {T} = (x = @cfunction myfun57023a Ptr{T} (Ref{T},); x)
Expand Down