Skip to content

Commit 0cb1adb

Browse files
authored
Use getsplit interface for InvokeCallInfo (#58328)
This makes invoke inlining work for CallInfo wrappers, e.g. - JuliaComputing/DAECompiler.jl#23 - JuliaDebug/Cthulhu.jl#640 I think this is probably the cleanest way to do it. Other ways might be to refactor InvokeCallInfo to wrap around a generic call info, but we already have this interface for callinfos, so might as well try to use it.
1 parent 6180ca0 commit 0cb1adb

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Compiler/src/ssair/inlining.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,14 +1159,18 @@ function is_builtin(𝕃ₒ::AbstractLattice, s::Signature)
11591159
end
11601160

11611161
function handle_invoke_call!(todo::Vector{Pair{Int,Any}},
1162-
ir::IRCode, idx::Int, stmt::Expr, info::InvokeCallInfo, flag::UInt32,
1162+
ir::IRCode, idx::Int, stmt::Expr, @nospecialize(info), flag::UInt32,
11631163
sig::Signature, state::InliningState)
1164-
match = info.match
1164+
nspl = nsplit(info)
1165+
nspl == 0 && return nothing # e.g. InvokeCICallInfo
1166+
@assert nspl == 1
1167+
mresult = getsplit(info, 1)
1168+
match = mresult.matches[1]
11651169
if !match.fully_covers
11661170
# TODO: We could union split out the signature check and continue on
11671171
return nothing
11681172
end
1169-
result = info.result
1173+
result = getresult(info, 1)
11701174
if isa(result, ConcreteResult)
11711175
item = concrete_result_item(result, info, state)
11721176
elseif isa(result, SemiConcreteResult)
@@ -1648,7 +1652,7 @@ function assemble_inline_todo!(ir::IRCode, state::InliningState)
16481652
handle_opaque_closure_call!(todo, ir, idx, stmt, info, flag, sig, state)
16491653
elseif isa(info, ModifyOpInfo)
16501654
handle_modifyop!_call!(ir, idx, stmt, info, state)
1651-
elseif isa(info, InvokeCallInfo)
1655+
elseif sig.f === Core.invoke
16521656
handle_invoke_call!(todo, ir, idx, stmt, info, flag, sig, state)
16531657
elseif isa(info, FinalizerInfo)
16541658
handle_finalizer_call!(ir, idx, stmt, info, state)

Compiler/src/stmtinfo.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ struct InvokeCICallInfo <: CallInfo
278278
end
279279
add_edges_impl(edges::Vector{Any}, info::InvokeCICallInfo) =
280280
add_inlining_edge!(edges, info.edge)
281+
nsplit_impl(info::InvokeCICallInfo) = 0
281282

282283
"""
283284
info::InvokeCallInfo
@@ -390,6 +391,11 @@ function add_inlining_edge!(edges::Vector{Any}, edge::CodeInstance)
390391
nothing
391392
end
392393

394+
nsplit_impl(info::InvokeCallInfo) = 1
395+
getsplit_impl(info::InvokeCallInfo, idx::Int) = (@assert idx == 1; MethodLookupResult(Core.MethodMatch[info.match],
396+
WorldRange(typemin(UInt), typemax(UInt)), false))
397+
getresult_impl(info::InvokeCallInfo, idx::Int) = (@assert idx == 1; info.result)
398+
393399

394400
"""
395401
info::OpaqueClosureCallInfo

0 commit comments

Comments
 (0)