@@ -577,11 +577,11 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs::
577
577
@assert nparams == fieldcount (mtype)
578
578
if ! (i == ncases && fully_covered)
579
579
for i = 1 : nparams
580
- a, m = fieldtype (atype, i), fieldtype (mtype, i)
580
+ aft, mft = fieldtype (atype, i), fieldtype (mtype, i)
581
581
# If this is always true, we don't need to check for it
582
- a <: m && continue
582
+ aft <: mft && continue
583
583
# Generate isa check
584
- isa_expr = Expr (:call , isa, argexprs[i], m )
584
+ isa_expr = Expr (:call , isa, argexprs[i], mft )
585
585
ssa = insert_node_here! (compact, NewInstruction (isa_expr, Bool, line))
586
586
if cond === true
587
587
cond = ssa
@@ -600,10 +600,10 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs::
600
600
for i = 1 : nparams
601
601
argex = argexprs[i]
602
602
(isa (argex, SSAValue) || isa (argex, Argument)) || continue
603
- a, m = fieldtype (atype, i), fieldtype (mtype, i)
604
- if ! (a <: m )
603
+ aft, mft = fieldtype (atype, i), fieldtype (mtype, i)
604
+ if ! (aft <: mft )
605
605
argexprs′[i] = insert_node_here! (compact,
606
- NewInstruction (PiNode (argex, m ), m , line))
606
+ NewInstruction (PiNode (argex, mft ), mft , line))
607
607
end
608
608
end
609
609
end
@@ -964,7 +964,8 @@ function analyze_method!(match::MethodMatch, argtypes::Vector{Any},
964
964
if ! match. fully_covers
965
965
# type-intersection was not able to give us a simple list of types, so
966
966
# ir_inline_unionsplit won't be able to deal with inlining this
967
- if ! (spec_types isa DataType && length (spec_types. parameters) == length (argtypes) && ! isvarargtype (spec_types. parameters[end ]))
967
+ if ! (spec_types isa DataType && length (spec_types. parameters) == npassedargs &&
968
+ ! isvarargtype (spec_types. parameters[end ]))
968
969
return nothing
969
970
end
970
971
end
@@ -1374,16 +1375,18 @@ function compute_inlining_cases(@nospecialize(info::CallInfo), flag::UInt32, sig
1374
1375
joint_effects = merge_effects (joint_effects, info_effects (result, match, state))
1375
1376
split_fully_covered |= match. fully_covers
1376
1377
if ! validate_sparams (match. sparams)
1377
- if ! match. fully_covers
1378
- handled_all_cases = false
1379
- continue
1380
- end
1381
- if revisit_idx === nothing
1382
- revisit_idx = (i, j, all_result_count)
1378
+ if match. fully_covers
1379
+ if revisit_idx === nothing
1380
+ revisit_idx = (i, j, all_result_count)
1381
+ else
1382
+ handled_all_cases = false
1383
+ revisit_idx = nothing
1384
+ end
1383
1385
else
1384
1386
handled_all_cases = false
1385
- revisit_idx = nothing
1386
1387
end
1388
+ elseif ! (match. spec_types <: match.method.sig ) # the requirement for correct union-split
1389
+ handled_all_cases = false
1387
1390
else
1388
1391
handled_all_cases &= handle_any_const_result! (cases,
1389
1392
result, match, argtypes, info, flag, state; allow_abstract= true , allow_typevars= false )
@@ -1418,14 +1421,15 @@ function handle_call!(todo::Vector{Pair{Int,Any}},
1418
1421
cases = compute_inlining_cases (info, flag, sig, state)
1419
1422
cases === nothing && return nothing
1420
1423
cases, all_covered, joint_effects = cases
1421
- handle_cases! (todo, ir, idx, stmt, argtypes_to_type (sig. argtypes), cases,
1422
- all_covered, joint_effects)
1424
+ atype = argtypes_to_type (sig. argtypes)
1425
+ handle_cases! (todo, ir, idx, stmt, atype, cases, all_covered, joint_effects)
1423
1426
end
1424
1427
1425
1428
function handle_match! (cases:: Vector{InliningCase} ,
1426
1429
match:: MethodMatch , argtypes:: Vector{Any} , @nospecialize (info:: CallInfo ), flag:: UInt32 ,
1427
1430
state:: InliningState ;
1428
- allow_abstract:: Bool , allow_typevars:: Bool , volatile_inf_result:: Union{Nothing,VolatileInferenceResult} )
1431
+ allow_abstract:: Bool , allow_typevars:: Bool ,
1432
+ volatile_inf_result:: Union{Nothing,VolatileInferenceResult} )
1429
1433
spec_types = match. spec_types
1430
1434
allow_abstract || isdispatchtuple (spec_types) || return false
1431
1435
# We may see duplicated dispatch signatures here when a signature gets widened
@@ -1512,19 +1516,19 @@ function concrete_result_item(result::ConcreteResult, @nospecialize(info::CallIn
1512
1516
end
1513
1517
1514
1518
function handle_cases! (todo:: Vector{Pair{Int,Any}} , ir:: IRCode , idx:: Int , stmt:: Expr ,
1515
- @nospecialize (atype), cases:: Vector{InliningCase} , fully_covered :: Bool ,
1519
+ @nospecialize (atype), cases:: Vector{InliningCase} , all_covered :: Bool ,
1516
1520
joint_effects:: Effects )
1517
1521
# If we only have one case and that case is fully covered, we may either
1518
1522
# be able to do the inlining now (for constant cases), or push it directly
1519
1523
# onto the todo list
1520
- if fully_covered && length (cases) == 1
1524
+ if all_covered && length (cases) == 1
1521
1525
handle_single_case! (todo, ir, idx, stmt, cases[1 ]. item)
1522
1526
elseif length (cases) > 0
1523
1527
isa (atype, DataType) || return nothing
1524
1528
for case in cases
1525
1529
isa (case. sig, DataType) || return nothing
1526
1530
end
1527
- push! (todo, idx=> UnionSplit (fully_covered , atype, cases))
1531
+ push! (todo, idx=> UnionSplit (all_covered , atype, cases))
1528
1532
else
1529
1533
add_flag! (ir[SSAValue (idx)], flags_for_effects (joint_effects))
1530
1534
end
0 commit comments