@@ -1034,18 +1034,22 @@ function inline_invoke!(
10341034 # TODO : We could union split out the signature check and continue on
10351035 return nothing
10361036 end
1037- argtypes = invoke_rewrite (sig. argtypes)
10381037 result = info. result
1039- if isa (result, InferenceResult)
1040- (; mi) = item = InliningTodo (result, argtypes)
1041- validate_sparams (mi. sparam_vals) || return nothing
1042- if argtypes_to_type (argtypes) <: mi.def.sig
1043- state. mi_cache != = nothing && (item = resolve_todo (item, state, flag))
1044- handle_single_case! (ir, idx, stmt, item, todo, state. params, true )
1045- return nothing
1038+ if isa (result, ConstResult)
1039+ item = const_result_item (result, state)
1040+ else
1041+ argtypes = invoke_rewrite (sig. argtypes)
1042+ if isa (result, InferenceResult)
1043+ (; mi) = item = InliningTodo (result, argtypes)
1044+ validate_sparams (mi. sparam_vals) || return nothing
1045+ if argtypes_to_type (argtypes) <: mi.def.sig
1046+ state. mi_cache != = nothing && (item = resolve_todo (item, state, flag))
1047+ handle_single_case! (ir, idx, stmt, item, todo, state. params, true )
1048+ return nothing
1049+ end
10461050 end
1051+ item = analyze_method! (match, argtypes, flag, state)
10471052 end
1048- item = analyze_method! (match, argtypes, flag, state)
10491053 handle_single_case! (ir, idx, stmt, item, todo, state. params, true )
10501054 return nothing
10511055end
@@ -1241,28 +1245,18 @@ function handle_const_call!(
12411245 for match in meth
12421246 j += 1
12431247 result = results[j]
1244- if result === false
1245- # Inference determined that this call is guaranteed to throw.
1246- # Do not inline.
1247- fully_covered = false
1248- continue
1249- end
12501248 if isa (result, ConstResult)
1251- if ! isdefined (result, :result ) || ! is_inlineable_constant (result. result)
1252- case = compileable_specialization (state. et, result. mi, EFFECTS_TOTAL)
1253- else
1254- case = ConstantCase (quoted (result. result))
1255- end
1249+ case = const_result_item (result, state)
12561250 signature_union = Union{signature_union, result. mi. specTypes}
12571251 push! (cases, InliningCase (result. mi. specTypes, case))
12581252 continue
1259- end
1260- if result === nothing
1253+ elseif isa (result, InferenceResult)
1254+ signature_union = Union{signature_union, result. linfo. specTypes}
1255+ fully_covered &= handle_inf_result! (result, argtypes, flag, state, cases)
1256+ else
1257+ @assert result === nothing
12611258 signature_union = Union{signature_union, match. spec_types}
12621259 fully_covered &= handle_match! (match, argtypes, flag, state, cases)
1263- else
1264- signature_union = Union{signature_union, result. linfo. specTypes}
1265- fully_covered &= handle_const_result! (result, argtypes, flag, state, cases)
12661260 end
12671261 end
12681262 end
@@ -1296,7 +1290,7 @@ function handle_match!(
12961290 return true
12971291end
12981292
1299- function handle_const_result ! (
1293+ function handle_inf_result ! (
13001294 result:: InferenceResult , argtypes:: Vector{Any} , flag:: UInt8 , state:: InliningState ,
13011295 cases:: Vector{InliningCase} )
13021296 (; mi) = item = InliningTodo (result, argtypes)
@@ -1309,6 +1303,14 @@ function handle_const_result!(
13091303 return true
13101304end
13111305
1306+ function const_result_item (result:: ConstResult , state:: InliningState )
1307+ if ! isdefined (result, :result ) || ! is_inlineable_constant (result. result)
1308+ return compileable_specialization (state. et, result. mi, EFFECTS_TOTAL)
1309+ else
1310+ return ConstantCase (quoted (result. result))
1311+ end
1312+ end
1313+
13121314function handle_cases! (ir:: IRCode , idx:: Int , stmt:: Expr , @nospecialize (atype),
13131315 cases:: Vector{InliningCase} , fully_covered:: Bool , todo:: Vector{Pair{Int, Any}} ,
13141316 params:: OptimizationParams )
@@ -1375,7 +1377,11 @@ function assemble_inline_todo!(ir::IRCode, state::InliningState)
13751377 ir, idx, stmt, result, flag,
13761378 sig, state, todo)
13771379 else
1378- item = analyze_method! (info. match, sig. argtypes, flag, state)
1380+ if isa (result, ConstResult)
1381+ item = const_result_item (result, state)
1382+ else
1383+ item = analyze_method! (info. match, sig. argtypes, flag, state)
1384+ end
13791385 handle_single_case! (ir, idx, stmt, item, todo, state. params)
13801386 end
13811387 continue
0 commit comments