From 8b449738a8a71097fea0fe62df976f9db94bfb0c Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Mon, 2 Nov 2020 20:16:57 -0500 Subject: [PATCH] Split Core.Compiler.optimize --- base/compiler/optimize.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index 90324b9665175..0d6eaec0f3142 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -179,11 +179,11 @@ function stmt_affects_purity(@nospecialize(stmt), ir) return true end -# run the optimization work -function optimize(opt::OptimizationState, params::OptimizationParams, @nospecialize(result)) +# Convert IRCode back to CodeInfo and compute inlining cost and sideeffects +function finish(opt::OptimizationState, params::OptimizationParams, ir, @nospecialize(result)) def = opt.linfo.def nargs = Int(opt.nargs) - 1 - @timeit "optimizer" ir = run_passes(opt.src, nargs, opt) + force_noinline = _any(@nospecialize(x) -> isexpr(x, :meta) && x.args[1] === :noinline, ir.meta) # compute inlining and other related optimizations @@ -271,6 +271,13 @@ function optimize(opt::OptimizationState, params::OptimizationParams, @nospecial nothing end +# run the optimization work +function optimize(opt::OptimizationState, params::OptimizationParams, @nospecialize(result)) + nargs = Int(opt.nargs) - 1 + @timeit "optimizer" ir = run_passes(opt.src, nargs, opt) + finish(opt, params, ir, result) +end + # whether `f` is pure for inference function is_pure_intrinsic_infer(f::IntrinsicFunction)