From f982445dd1e93130d861bca0fd63a23cc9dab29c Mon Sep 17 00:00:00 2001 From: Prem Chintalapudi Date: Wed, 5 Jul 2023 11:11:25 -0400 Subject: [PATCH] Take advantage of some simplifications --- src/mcgen.jl | 8 +------- src/optim.jl | 48 ++++++++++-------------------------------------- 2 files changed, 11 insertions(+), 45 deletions(-) diff --git a/src/mcgen.jl b/src/mcgen.jl index 36ac072b..34202c83 100644 --- a/src/mcgen.jl +++ b/src/mcgen.jl @@ -10,13 +10,7 @@ function prepare_execution!(@nospecialize(job::CompilerJob), mod::LLVM.Module) add!(mpm, RecomputeGlobalsAAPass()) add!(mpm, GlobalOptPass()) resolve_cpu_references!(mod) - add!(mpm) do m, mam - if resolve_cpu_references!(m) - no_analyses_preserved() - else - all_analyses_preserved() - end - end + add!(legacy2newpm(resolve_cpu_references!), mpm) add!(mpm, GlobalDCEPass()) add!(mpm, StripDeadPrototypesPass()) run!(mpm, mod, nothing, [BasicAA(), ScopedNoAliasAA(), TypeBasedAA(), GlobalsAA()]) diff --git a/src/optim.jl b/src/optim.jl index f04ba754..1a5ceb0c 100644 --- a/src/optim.jl +++ b/src/optim.jl @@ -171,9 +171,11 @@ function addOptimizationPasses!(pm, opt_level=2) aggressive_dce!(pm) end -const add_verification_passes = false -const BasicSimplifyCFGOptions = SimplifyCFGPassOptions(true, true, true, true, false, false, 1) -const AggressiveSimplifyCFGOptions = SimplifyCFGPassOptions(true, true, true, true, true, false, 1) +if use_newpm + const add_verification_passes = false + const BasicSimplifyCFGOptions = SimplifyCFGPassOptions(true, true, true, true, false, false, 1) + const AggressiveSimplifyCFGOptions = SimplifyCFGPassOptions(true, true, true, true, true, false, 1) +end function buildEarlySimplificationPipeline(mpm, @nospecialize(job::CompilerJob), opt_level) if add_verification_passes @@ -207,13 +209,7 @@ function buildEarlyOptimizerPipeline(mpm, @nospecialize(job::CompilerJob), opt_l add!(fpm, LowerConstantIntrinsicsPass()) end end - add!(mpm) do m, mam - if cpu_features!(m) - no_analyses_preserved() - else - all_analyses_preserved() - end - end + add!(legacy2newpm(cpu_features!), mpm) if opt_level >= 1 add!(mpm, NewPMFunctionPassManager) do fpm if opt_level >= 2 @@ -341,40 +337,16 @@ function buildKernelIntrinsicLoweringPipeline(mpm, @nospecialize(job::CompilerJo # GC lowering is the last pass that may introduce calls to the runtime library, # and thus additional uses of the kernel state intrinsic. # TODO: now that all kernel state-related passes are being run here, merge some? - add!(mpm) do m, mam - if add_kernel_state!(m) - return no_analyses_preserved() - else - return all_analyses_preserved() - end - end + add!(legacy2newpm(add_kernel_state!), mpm) add!(mpm, NewPMFunctionPassManager) do fpm - add!(fpm) do f, fam - if lower_kernel_state!(f) - return no_analyses_preserved() - else - return all_analyses_preserved() - end - end - end - add!(mpm) do m, mam - if cleanup_kernel_state!(m) - return no_analyses_preserved() - else - return all_analyses_preserved() - end + add!(legacy2newpm(lower_kernel_state!), fpm) end + add!(legacy2newpm(cleanup_kernel_state!), mpm) end add!(mpm, NewPMFunctionPassManager) do fpm add!(fpm, ADCEPass()) end - add!(mpm) do m, mam - if lower_ptls!(m) - return no_analyses_preserved() - else - return all_analyses_preserved() - end - end + add!(legacy2newpm(lower_ptls!), mpm) add!(mpm, NewPMFunctionPassManager) do fpm add!(fpm, LowerExcHandlersPass()) add!(fpm, LateLowerGCPass())