diff --git a/llvm/include/llvm/Transforms/IPO/Inliner.h b/llvm/include/llvm/Transforms/IPO/Inliner.h --- a/llvm/include/llvm/Transforms/IPO/Inliner.h +++ b/llvm/include/llvm/Transforms/IPO/Inliner.h @@ -131,9 +131,9 @@ /// before run is called, as part of pass pipeline building. CGSCCPassManager &getPM() { return PM; } - /// Allow adding module-level analyses benefiting the contained CGSCC passes. - template void addRequiredModuleAnalysis() { - MPM.addPass(RequireAnalysisPass()); + /// Allow adding module-level passes benefiting the contained CGSCC passes. + template void addModulePass(T Pass) { + MPM.addPass(std::move(Pass)); } private: diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -976,11 +976,15 @@ // Require the GlobalsAA analysis for the module so we can query it within // the CGSCC pipeline. - MIWP.addRequiredModuleAnalysis(); + 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. - MIWP.addRequiredModuleAnalysis(); + MIWP.addModulePass(RequireAnalysisPass()); // Now begin the main postorder CGSCC pipeline. // FIXME: The current CGSCC pipeline has its origins in the legacy pass @@ -1242,6 +1246,7 @@ // 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(InvalidateAnalysisPass()); MPM.addPass(RequireAnalysisPass()); FunctionPassManager OptimizePM(DebugLogging);