diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index aa42fb3771141..b12b4ee3e0e59 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -856,11 +856,13 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level, // Require the GlobalsAA analysis for the module so we can query it within // the CGSCC pipeline. - MIWP.addModulePass(RequireAnalysisPass()); - // Invalidate AAManager so it can be recreated and pick up the newly available - // GlobalsAA. - MIWP.addModulePass( - createModuleToFunctionPassAdaptor(InvalidateAnalysisPass())); + if (EnableGlobalAnalyses) { + MIWP.addModulePass(RequireAnalysisPass()); + // Invalidate AAManager so it can be recreated and pick up the newly + // available GlobalsAA. + MIWP.addModulePass( + createModuleToFunctionPassAdaptor(InvalidateAnalysisPass())); + } // Require the ProfileSummaryAnalysis for the module so we can query it within // the inliner pass. @@ -1328,7 +1330,8 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level, // information for all local globals here, the late loop passes and notably // the vectorizer will be able to use them to help recognize vectorizable // memory operations. - MPM.addPass(RecomputeGlobalsAAPass()); + if (EnableGlobalAnalyses) + MPM.addPass(RecomputeGlobalsAAPass()); invokeOptimizerEarlyEPCallbacks(MPM, Level); @@ -1820,11 +1823,13 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, // Require the GlobalsAA analysis for the module so we can query it within // MainFPM. - MPM.addPass(RequireAnalysisPass()); - // Invalidate AAManager so it can be recreated and pick up the newly available - // GlobalsAA. - MPM.addPass( - createModuleToFunctionPassAdaptor(InvalidateAnalysisPass())); + if (EnableGlobalAnalyses) { + MPM.addPass(RequireAnalysisPass()); + // Invalidate AAManager so it can be recreated and pick up the newly + // available GlobalsAA. + MPM.addPass( + createModuleToFunctionPassAdaptor(InvalidateAnalysisPass())); + } FunctionPassManager MainFPM; MainFPM.addPass(createFunctionToLoopPassAdaptor(