Skip to content

Commit 726c8d2

Browse files
authored
update --inline=no to still do devirtualization (JuliaLang#35330)
1 parent 539c492 commit 726c8d2

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

base/compiler/ssair/inlining.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,12 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths
707707

708708
isconst, src = find_inferred(mi, atypes, sv, stmttyp)
709709
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
712716
end
713717
if src === nothing
714718
return spec_lambda(atype_unlimited, sv, invoke_data)
@@ -717,7 +721,7 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths
717721
src_inferred = ccall(:jl_ir_flag_inferred, Bool, (Any,), src)
718722
src_inlineable = ccall(:jl_ir_flag_inlineable, Bool, (Any,), src)
719723

720-
if !(src_inferred && src_inlineable)
724+
if !(src_inferred && src_inlineable && sv.params.inlining)
721725
return spec_lambda(atype_unlimited, sv, invoke_data)
722726
end
723727

@@ -964,9 +968,6 @@ function process_simple!(ir::IRCode, idx::Int, params::Params)
964968
return nothing
965969
end
966970

967-
# Bail out here if inlining is disabled
968-
params.inlining || return nothing
969-
970971
# Handle invoke
971972
invoke_data = nothing
972973
if sig.f === Core.invoke && length(sig.atypes) >= 3
@@ -985,7 +986,7 @@ function process_simple!(ir::IRCode, idx::Int, params::Params)
985986
(invoke_data === nothing || sig.atype <: invoke_data.types0) || return nothing
986987

987988
# 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)
989990
return nothing
990991
end
991992
return (sig, invoke_data)
@@ -1197,10 +1198,10 @@ function early_inline_special_case(ir::IRCode, s::Signature, e::Expr, params::Pa
11971198
return nothing
11981199
end
11991200

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)
12011202
typ = ir.types[idx]
12021203
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, :!==)
12041205
# special-case inliner for !== that precedes _methods_by_ftype union splitting
12051206
# and that works, even though inference generally avoids inferring the `!==` Method
12061207
if isa(typ, Const)
@@ -1212,7 +1213,7 @@ function late_inline_special_case!(ir::IRCode, sig::Signature, idx::Int, stmt::E
12121213
not_call = Expr(:call, GlobalRef(Core.Intrinsics, :not_int), cmp_call_ssa)
12131214
ir[SSAValue(idx)] = not_call
12141215
return true
1215-
elseif length(atypes) == 3 && istopfunction(f, :(>:))
1216+
elseif params.inlining && length(atypes) == 3 && istopfunction(f, :(>:))
12161217
# special-case inliner for issupertype
12171218
# that works, even though inference generally avoids inferring the `>:` Method
12181219
if isa(typ, Const)

0 commit comments

Comments
 (0)