Skip to content

Commit 0a59892

Browse files
committed
use and boost inlining_cost
1 parent c601261 commit 0a59892

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,8 +1286,6 @@ function const_prop_methodinstance_heuristic(interp::AbstractInterpreter,
12861286
elseif is_stmt_noinline(flag)
12871287
# this call won't be inlined, thus this constant-prop' will most likely be unfruitful
12881288
return false
1289-
elseif any_const_prop_profitable_args(effects, arginfo.argtypes)
1290-
return true
12911289
end
12921290
# Peek at the inferred result for the method to determine if the optimizer
12931291
# was able to cut it down to something simple (inlineable in particular).
@@ -1297,8 +1295,9 @@ function const_prop_methodinstance_heuristic(interp::AbstractInterpreter,
12971295
if isa(code, CodeInstance)
12981296
inferred = @atomic :monotonic code.inferred
12991297
rt = code.rettype
1298+
boost = any_const_prop_profitable_args(effects, arginfo.argtypes)
13001299
# TODO propagate a specific `CallInfo` that conveys information about this call
1301-
iinfo = InliningInfo(rt, mi, arginfo.argtypes, NoCallInfo(), IR_FLAG_NULL)
1300+
iinfo = InliningInfo(rt, mi, arginfo.argtypes, NoCallInfo(), IR_FLAG_NULL, boost)
13021301
if inlining_policy(interp, inferred, iinfo) !== nothing
13031302
return true
13041303
end

base/compiler/optimize.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ is_source_inferred(@nospecialize src::MaybeCompressed) =
5757
struct InlineabilityInfo
5858
rt
5959
mi::MethodInstance
60-
InlineabilityInfo(@nospecialize(rt), mi::MethodInstance) = new(rt, mi)
60+
boost::Bool
61+
InlineabilityInfo(@nospecialize(rt), mi::MethodInstance, boost::Bool=false) = new(rt, mi, boost)
6162
end
6263

6364
"""
@@ -76,7 +77,7 @@ function is_inlineable(interp::AbstractInterpreter, @nospecialize(src::MaybeComp
7677
params = OptimizationParams(interp)
7778
cost_threshold = default = params.inline_cost_threshold
7879
# if the method is declared as `@inline`, increase the cost threshold 20x
79-
if is_declared_inline(src)
80+
if is_declared_inline(src) || ibinfo.boost
8081
cost_threshold += 19*default
8182
end
8283
if ibinfo !== nothing
@@ -106,9 +107,10 @@ struct InliningInfo
106107
argtypes::Vector{Any}
107108
info::CallInfo
108109
stmt_flag::UInt8
110+
boost::Bool
109111
function InliningInfo(@nospecialize(rt), mi::MethodInstance, argtypes::Vector{Any},
110-
@nospecialize(info::CallInfo), stmt_flag::UInt8)
111-
return new(rt, mi, argtypes, info, stmt_flag)
112+
@nospecialize(info::CallInfo), stmt_flag::UInt8, boost::Bool=false)
113+
return new(rt, mi, argtypes, info, stmt_flag, boost)
112114
end
113115
end
114116

@@ -121,7 +123,8 @@ inlined by the inlining algorithm, otherwise return `nothing`.
121123
function inlining_policy(interp::AbstractInterpreter, @nospecialize(src), iinfo::InliningInfo)
122124
if isa(src, MaybeCompressed)
123125
if is_source_inferred(src)
124-
if is_stmt_inline(iinfo.stmt_flag) || is_inlineable(interp, src, InlineabilityInfo(iinfo.rt, iinfo.mi))
126+
if (is_stmt_inline(iinfo.stmt_flag) ||
127+
is_inlineable(interp, src, InlineabilityInfo(iinfo.rt, iinfo.mi, iinfo.boost)))
125128
return src
126129
end
127130
end

base/compiler/typeinfer.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,14 @@ function CodeInstance(interp::AbstractInterpreter, result::InferenceResult,
346346
relocatability, precompile)
347347
end
348348

349-
function maybe_compress_codeinfo(interp::AbstractInterpreter, mi::MethodInstance, ci::CodeInfo)
349+
function maybe_compress_codeinfo(interp::AbstractInterpreter, mi::MethodInstance, ci::CodeInfo,
350+
ipo_effects::Effects)
350351
def = mi.def
351352
isa(def, Method) || return ci
352353
if may_discard_trees(interp)
353354
cache_the_tree = ci.inferred && (
354355
is_inlineable(interp, ci, InlineabilityInfo(ci.rettype, mi)) ||
356+
ipo_effects.const_prop_profitable_args !== NO_PROFITABLE_ARGS || # TODO remove me?
355357
isa_compileable_sig(mi))
356358
else
357359
cache_the_tree = true
@@ -381,7 +383,7 @@ function transform_result_for_cache(interp::AbstractInterpreter,
381383
if inferred_result isa CodeInfo
382384
inferred_result.min_world = first(valid_worlds)
383385
inferred_result.max_world = last(valid_worlds)
384-
inferred_result = maybe_compress_codeinfo(interp, linfo, inferred_result)
386+
inferred_result = maybe_compress_codeinfo(interp, linfo, inferred_result, result.effects)
385387
end
386388
# The global cache can only handle objects that codegen understands
387389
if !isa(inferred_result, MaybeCompressed)

0 commit comments

Comments
 (0)