Skip to content

Commit

Permalink
Handle varargs in _compute_sparams
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Atol committed May 2, 2022
1 parent 2b21269 commit cc1f9e0
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,19 @@ function ir_inline_item!(compact::IncrementalCompact, idx::Int, argexprs::Vector
end
end
if !validate_sparams(sparam_vals)
sparam_vals = insert_node_here!(compact,
effect_free(NewInstruction(Expr(:call, Core._compute_sparams, item.mi.def, argexprs...), SimpleVector, topline)))
if def.isva
nonva_args = argexprs[1:end-1]
va_arg = argexprs[end]
tuple_call = Expr(:call, TOP_TUPLE, def, nonva_args...)
tuple_type = tuple_tfunc(Any[argextype(arg, compact) for arg in nonva_args])
tupl = insert_node_here!(compact, NewInstruction(tuple_call, tuple_type, topline))
apply_iter_expr = Expr(:call, Core._apply_iterate, iterate, Core._compute_sparams, tupl, va_arg)
sparam_vals = insert_node_here!(compact,
effect_free(NewInstruction(apply_iter_expr, SimpleVector, topline)))
else
sparam_vals = insert_node_here!(compact,
effect_free(NewInstruction(Expr(:call, Core._compute_sparams, def, argexprs...), SimpleVector, topline)))
end
end
# If the iterator already moved on to the next basic block,
# temporarily re-open in again.
Expand Down Expand Up @@ -458,7 +469,8 @@ function fix_va_argexprs!(compact::IncrementalCompact,
push!(tuple_typs, argextype(arg, compact))
end
tuple_typ = tuple_tfunc(tuple_typs)
push!(newargexprs, insert_node_here!(compact, NewInstruction(tuple_call, tuple_typ, line_idx)))
tuple_inst = NewInstruction(tuple_call, tuple_typ, line_idx)
push!(newargexprs, insert_node_here!(compact, tuple_inst))
return newargexprs
end

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

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

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

0 comments on commit cc1f9e0

Please sign in to comment.