Skip to content

Commit

Permalink
update --inline=no to still do devirtualization (JuliaLang#35330)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 8, 2020
1 parent 539c492 commit 726c8d2
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions base/compiler/ssair/inlining.jl
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,12 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths

isconst, src = find_inferred(mi, atypes, sv, stmttyp)
if isconst
add_backedge!(mi, sv)
return ConstantCase(src, method, Any[methsp...], metharg)
if sv.params.inlining
add_backedge!(mi, sv)
return ConstantCase(src, method, Any[methsp...], metharg)
else
return spec_lambda(atype_unlimited, sv, invoke_data)
end
end
if src === nothing
return spec_lambda(atype_unlimited, sv, invoke_data)
Expand All @@ -717,7 +721,7 @@ function analyze_method!(idx::Int, sig::Signature, @nospecialize(metharg), meths
src_inferred = ccall(:jl_ir_flag_inferred, Bool, (Any,), src)
src_inlineable = ccall(:jl_ir_flag_inlineable, Bool, (Any,), src)

if !(src_inferred && src_inlineable)
if !(src_inferred && src_inlineable && sv.params.inlining)
return spec_lambda(atype_unlimited, sv, invoke_data)
end

Expand Down Expand Up @@ -964,9 +968,6 @@ function process_simple!(ir::IRCode, idx::Int, params::Params)
return nothing
end

# Bail out here if inlining is disabled
params.inlining || return nothing

# Handle invoke
invoke_data = nothing
if sig.f === Core.invoke && length(sig.atypes) >= 3
Expand All @@ -985,7 +986,7 @@ function process_simple!(ir::IRCode, idx::Int, params::Params)
(invoke_data === nothing || sig.atype <: invoke_data.types0) || return nothing

# Special case inliners for regular functions
if late_inline_special_case!(ir, sig, idx, stmt) || is_return_type(sig.f)
if late_inline_special_case!(ir, sig, idx, stmt, params) || is_return_type(sig.f)
return nothing
end
return (sig, invoke_data)
Expand Down Expand Up @@ -1197,10 +1198,10 @@ function early_inline_special_case(ir::IRCode, s::Signature, e::Expr, params::Pa
return nothing
end

function late_inline_special_case!(ir::IRCode, sig::Signature, idx::Int, stmt::Expr)
function late_inline_special_case!(ir::IRCode, sig::Signature, idx::Int, stmt::Expr, params::Params)
typ = ir.types[idx]
f, ft, atypes = sig.f, sig.ft, sig.atypes
if length(atypes) == 3 && istopfunction(f, :!==)
if params.inlining && length(atypes) == 3 && istopfunction(f, :!==)
# special-case inliner for !== that precedes _methods_by_ftype union splitting
# and that works, even though inference generally avoids inferring the `!==` Method
if isa(typ, Const)
Expand All @@ -1212,7 +1213,7 @@ function late_inline_special_case!(ir::IRCode, sig::Signature, idx::Int, stmt::E
not_call = Expr(:call, GlobalRef(Core.Intrinsics, :not_int), cmp_call_ssa)
ir[SSAValue(idx)] = not_call
return true
elseif length(atypes) == 3 && istopfunction(f, :(>:))
elseif params.inlining && length(atypes) == 3 && istopfunction(f, :(>:))
# special-case inliner for issupertype
# that works, even though inference generally avoids inferring the `>:` Method
if isa(typ, Const)
Expand Down

0 comments on commit 726c8d2

Please sign in to comment.