Skip to content

Commit a8dbd6a

Browse files
author
Ian Atol
committed
Handle varargs in _compute_sparams
1 parent 2b21269 commit a8dbd6a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

base/compiler/ssair/inlining.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,19 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
360360
end
361361
end
362362
if !validate_sparams(sparam_vals)
363-
sparam_vals = insert_node_here!(compact,
364-
effect_free(NewInstruction(Expr(:call, Core._compute_sparams, item.mi.def, argexprs...), SimpleVector, topline)))
363+
if def.isva
364+
nonva_args = argexprs[1:end-1]
365+
va_arg = argexprs[end]
366+
tuple_call = Expr(:call, TOP_TUPLE, def, nonva_args...)
367+
tuple_type = tuple_tfunc([argextype(arg, compact) for arg in nonva_args])
368+
tupl = insert_node_here!(compact, NewInstruction(tuple_call, tuple_type, topline))
369+
apply_iter_expr = Expr(:call, Core._apply_iterate, iterate, Core._compute_sparams, tupl, va_arg)
370+
sparam_vals = insert_node_here!(compact,
371+
effect_free(NewInstruction(apply_iter_expr, SimpleVector, topline)))
372+
else
373+
sparam_vals = insert_node_here!(compact,
374+
effect_free(NewInstruction(Expr(:call, Core._compute_sparams, def, argexprs...), SimpleVector, topline)))
375+
end
365376
end
366377
# If the iterator already moved on to the next basic block,
367378
# temporarily re-open in again.
@@ -458,7 +469,8 @@ function fix_va_argexprs!(compact::IncrementalCompact,
458469
push!(tuple_typs, argextype(arg, compact))
459470
end
460471
tuple_typ = tuple_tfunc(tuple_typs)
461-
push!(newargexprs, insert_node_here!(compact, NewInstruction(tuple_call, tuple_typ, line_idx)))
472+
tuple_inst = NewInstruction(tuple_call, tuple_typ, line_idx)
473+
push!(newargexprs, insert_node_here!(compact, tuple_inst))
462474
return newargexprs
463475
end
464476

@@ -1239,7 +1251,7 @@ function analyze_single_call!(
12391251
local any_fully_covered = false
12401252
local handled_all_cases = true
12411253
local revisit_idx = nothing
1242-
local only_method = nothing
1254+
local only_method = nothing # tri-valued: nothing if unknown, false if proven untrue, otherwise the method itself
12431255
local meth::MethodLookupResult
12441256
for i in 1:length(infos)
12451257
meth = infos[i].results
@@ -1443,9 +1455,7 @@ function inline_const_if_inlineable!(inst::Instruction)
14431455
end
14441456

14451457
function assemble_inline_todo!(ir::IRCode, state::InliningState)
1446-
# todo = (inline_idx, (isva, isinvoke, na), method, spvals, inline_linetable, inline_ir, lie)
14471458
todo = Pair{Int, Any}[]
1448-
et = state.et
14491459

14501460
for idx in 1:length(ir.stmts)
14511461
simpleres = process_simple!(ir, idx, state, todo)

0 commit comments

Comments
 (0)