@@ -707,8 +707,12 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths
707
707
708
708
isconst, src = find_inferred (mi, atypes, sv, stmttyp)
709
709
if isconst
710
- add_backedge! (mi, sv)
711
- return ConstantCase (src, method, Any[methsp... ], metharg)
710
+ if sv. params. inlining
711
+ add_backedge! (mi, sv)
712
+ return ConstantCase (src, method, Any[methsp... ], metharg)
713
+ else
714
+ return spec_lambda (atype_unlimited, sv, invoke_data)
715
+ end
712
716
end
713
717
if src === nothing
714
718
return spec_lambda (atype_unlimited, sv, invoke_data)
@@ -717,7 +721,7 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths
717
721
src_inferred = ccall (:jl_ir_flag_inferred , Bool, (Any,), src)
718
722
src_inlineable = ccall (:jl_ir_flag_inlineable , Bool, (Any,), src)
719
723
720
- if ! (src_inferred && src_inlineable)
724
+ if ! (src_inferred && src_inlineable && sv . params . inlining )
721
725
return spec_lambda (atype_unlimited, sv, invoke_data)
722
726
end
723
727
@@ -964,9 +968,6 @@ function process_simple!(ir::IRCode, idx::Int, params::Params)
964
968
return nothing
965
969
end
966
970
967
- # Bail out here if inlining is disabled
968
- params. inlining || return nothing
969
-
970
971
# Handle invoke
971
972
invoke_data = nothing
972
973
if sig. f === Core. invoke && length (sig. atypes) >= 3
@@ -985,7 +986,7 @@ function process_simple!(ir::IRCode, idx::Int, params::Params)
985
986
(invoke_data === nothing || sig. atype <: invoke_data.types0 ) || return nothing
986
987
987
988
# Special case inliners for regular functions
988
- if late_inline_special_case! (ir, sig, idx, stmt) || is_return_type (sig. f)
989
+ if late_inline_special_case! (ir, sig, idx, stmt, params ) || is_return_type (sig. f)
989
990
return nothing
990
991
end
991
992
return (sig, invoke_data)
@@ -1197,10 +1198,10 @@ function early_inline_special_case(ir::IRCode, s::Signature, e::Expr, params::Pa
1197
1198
return nothing
1198
1199
end
1199
1200
1200
- function late_inline_special_case! (ir:: IRCode , sig:: Signature , idx:: Int , stmt:: Expr )
1201
+ function late_inline_special_case! (ir:: IRCode , sig:: Signature , idx:: Int , stmt:: Expr , params :: Params )
1201
1202
typ = ir. types[idx]
1202
1203
f, ft, atypes = sig. f, sig. ft, sig. atypes
1203
- if length (atypes) == 3 && istopfunction (f, :!= = )
1204
+ if params . inlining && length (atypes) == 3 && istopfunction (f, :!= = )
1204
1205
# special-case inliner for !== that precedes _methods_by_ftype union splitting
1205
1206
# and that works, even though inference generally avoids inferring the `!==` Method
1206
1207
if isa (typ, Const)
@@ -1212,7 +1213,7 @@ function late_inline_special_case!(ir::IRCode, sig::Signature, idx::Int, stmt::E
1212
1213
not_call = Expr (:call , GlobalRef (Core. Intrinsics, :not_int ), cmp_call_ssa)
1213
1214
ir[SSAValue (idx)] = not_call
1214
1215
return true
1215
- elseif length (atypes) == 3 && istopfunction (f, :(> :))
1216
+ elseif params . inlining && length (atypes) == 3 && istopfunction (f, :(> :))
1216
1217
# special-case inliner for issupertype
1217
1218
# that works, even though inference generally avoids inferring the `>:` Method
1218
1219
if isa (typ, Const)
0 commit comments