From b9c18a2460a038e3c30db13da150c1c00249517c Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 18 Sep 2018 16:30:49 -0400 Subject: [PATCH] always obey inline declarations if the calling signature is concrete This implements the suggestion in https://github.com/JuliaLang/julia/pull/27857#issuecomment-421109530 --- 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 870b83d50745f..6a202b40a3024 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -230,15 +230,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