From 4afbacb0ab3629b248f8d012dd7e8e7e5f9a42a2 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 25 Sep 2018 17:45:45 -0400 Subject: [PATCH] always obey inline declarations if the calling signature is concrete (#29258) This implements the suggestion in https://github.com/JuliaLang/julia/pull/27857#issuecomment-421109530 (cherry picked from commit 8d6c1cebfd5cd97ebe33c9b84aa0f82335ed41a9) --- base/compiler/optimize.jl | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index ab9a1faaed7632..2bae748e8a27f6 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -234,15 +234,19 @@ function optimize(opt::OptimizationState, @nospecialize(result)) if force_noinline opt.src.inlineable = false elseif isa(def, Method) - bonus = 0 - if result ⊑ Tuple && !isbitstype(widenconst(result)) - bonus = opt.params.inline_tupleret_bonus - end - if opt.src.inlineable - # For functions declared @inline, increase the cost threshold 20x - bonus += opt.params.inline_cost_threshold*19 + if opt.src.inlineable && isdispatchtuple(opt.linfo.specTypes) + # obey @inline declaration if a dispatch barrier would not help + else + bonus = 0 + if result ⊑ Tuple && !isbitstype(widenconst(result)) + bonus = opt.params.inline_tupleret_bonus + end + if opt.src.inlineable + # For functions declared @inline, increase the cost threshold 20x + bonus += opt.params.inline_cost_threshold*19 + end + opt.src.inlineable = isinlineable(def, opt, bonus) end - opt.src.inlineable = isinlineable(def, opt, bonus) end nothing end