@@ -542,11 +542,11 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs::
542
542
@assert nparams == fieldcount (mtype)
543
543
if ! (i == ncases && fully_covered)
544
544
for i = 1 : nparams
545
- a, m = fieldtype (atype, i), fieldtype (mtype, i)
545
+ aft, mft = fieldtype (atype, i), fieldtype (mtype, i)
546
546
# If this is always true, we don't need to check for it
547
- a <: m && continue
547
+ aft <: mft && continue
548
548
# Generate isa check
549
- isa_expr = Expr (:call , isa, argexprs[i], m )
549
+ isa_expr = Expr (:call , isa, argexprs[i], mft )
550
550
ssa = insert_node_here! (compact, NewInstruction (isa_expr, Bool, line))
551
551
if cond === true
552
552
cond = ssa
@@ -565,10 +565,10 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, argexprs::
565
565
for i = 1 : nparams
566
566
argex = argexprs[i]
567
567
(isa (argex, SSAValue) || isa (argex, Argument)) || continue
568
- a, m = fieldtype (atype, i), fieldtype (mtype, i)
569
- if ! (a <: m )
568
+ aft, mft = fieldtype (atype, i), fieldtype (mtype, i)
569
+ if ! (aft <: mft )
570
570
argexprs′[i] = insert_node_here! (compact,
571
- NewInstruction (PiNode (argex, m ), m , line))
571
+ NewInstruction (PiNode (argex, mft ), mft , line))
572
572
end
573
573
end
574
574
end
@@ -944,7 +944,8 @@ function analyze_method!(match::MethodMatch, argtypes::Vector{Any},
944
944
if ! match. fully_covers
945
945
# type-intersection was not able to give us a simple list of types, so
946
946
# ir_inline_unionsplit won't be able to deal with inlining this
947
- if ! (spec_types isa DataType && length (spec_types. parameters) == length (argtypes) && ! isvarargtype (spec_types. parameters[end ]))
947
+ if ! (spec_types isa DataType && length (spec_types. parameters) == npassedargs &&
948
+ ! isvarargtype (spec_types. parameters[end ]))
948
949
return nothing
949
950
end
950
951
end
@@ -1355,16 +1356,18 @@ function compute_inlining_cases(@nospecialize(info::CallInfo), flag::UInt32, sig
1355
1356
joint_effects = merge_effects (joint_effects, info_effects (result, match, state))
1356
1357
split_fully_covered |= match. fully_covers
1357
1358
if ! validate_sparams (match. sparams)
1358
- if ! match. fully_covers
1359
- handled_all_cases = false
1360
- continue
1361
- end
1362
- if revisit_idx === nothing
1363
- revisit_idx = (i, j, all_result_count)
1359
+ if match. fully_covers
1360
+ if revisit_idx === nothing
1361
+ revisit_idx = (i, j, all_result_count)
1362
+ else
1363
+ handled_all_cases = false
1364
+ revisit_idx = nothing
1365
+ end
1364
1366
else
1365
1367
handled_all_cases = false
1366
- revisit_idx = nothing
1367
1368
end
1369
+ elseif ! (match. spec_types <: match.method.sig ) # the requirement for correct union-split
1370
+ handled_all_cases = false
1368
1371
else
1369
1372
handled_all_cases &= handle_any_const_result! (cases,
1370
1373
result, match, argtypes, info, flag, state; allow_abstract= true , allow_typevars= false )
@@ -1399,14 +1402,15 @@ function handle_call!(todo::Vector{Pair{Int,Any}},
1399
1402
cases = compute_inlining_cases (info, flag, sig, state)
1400
1403
cases === nothing && return nothing
1401
1404
cases, all_covered, joint_effects = cases
1402
- handle_cases! (todo, ir, idx, stmt, argtypes_to_type (sig. argtypes), cases,
1403
- all_covered, joint_effects)
1405
+ atype = argtypes_to_type (sig. argtypes)
1406
+ handle_cases! (todo, ir, idx, stmt, atype, cases, all_covered, joint_effects)
1404
1407
end
1405
1408
1406
1409
function handle_match! (cases:: Vector{InliningCase} ,
1407
1410
match:: MethodMatch , argtypes:: Vector{Any} , @nospecialize (info:: CallInfo ), flag:: UInt32 ,
1408
1411
state:: InliningState ;
1409
- allow_abstract:: Bool , allow_typevars:: Bool , volatile_inf_result:: Union{Nothing,VolatileInferenceResult} )
1412
+ allow_abstract:: Bool , allow_typevars:: Bool ,
1413
+ volatile_inf_result:: Union{Nothing,VolatileInferenceResult} )
1410
1414
spec_types = match. spec_types
1411
1415
allow_abstract || isdispatchtuple (spec_types) || return false
1412
1416
# We may see duplicated dispatch signatures here when a signature gets widened
@@ -1493,19 +1497,19 @@ function concrete_result_item(result::ConcreteResult, @nospecialize(info::CallIn
1493
1497
end
1494
1498
1495
1499
function handle_cases! (todo:: Vector{Pair{Int,Any}} , ir:: IRCode , idx:: Int , stmt:: Expr ,
1496
- @nospecialize (atype), cases:: Vector{InliningCase} , fully_covered :: Bool ,
1500
+ @nospecialize (atype), cases:: Vector{InliningCase} , all_covered :: Bool ,
1497
1501
joint_effects:: Effects )
1498
1502
# If we only have one case and that case is fully covered, we may either
1499
1503
# be able to do the inlining now (for constant cases), or push it directly
1500
1504
# onto the todo list
1501
- if fully_covered && length (cases) == 1
1505
+ if all_covered && length (cases) == 1
1502
1506
handle_single_case! (todo, ir, idx, stmt, cases[1 ]. item)
1503
1507
elseif length (cases) > 0
1504
1508
isa (atype, DataType) || return nothing
1505
1509
for case in cases
1506
1510
isa (case. sig, DataType) || return nothing
1507
1511
end
1508
- push! (todo, idx=> UnionSplit (fully_covered , atype, cases))
1512
+ push! (todo, idx=> UnionSplit (all_covered , atype, cases))
1509
1513
else
1510
1514
add_flag! (ir[SSAValue (idx)], flags_for_effects (joint_effects))
1511
1515
end
0 commit comments