diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 80a9c4d98fc15..699e1f6b0dfba 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1545,6 +1545,7 @@ PassBuilder::buildTapirLoweringPipeline(OptimizationLevel Level, // Rotate Loop - disable header duplication at -Oz LPM1.addPass(LoopRotatePass(Level != OptimizationLevel::Oz)); LPM2.addPass(IndVarSimplifyPass()); + LPM2.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap)); FunctionPassManager FPM(DebugLogging); FPM.addPass(createFunctionToLoopPassAdaptor( @@ -1623,27 +1624,15 @@ PassBuilder::buildTapirLoweringPipeline(OptimizationLevel Level, if (EnableSyntheticCounts) MPM.addPass(SyntheticCountsPropagation()); - // Require the GlobalsAA analysis for the module so we can query it within - // the CGSCC pipeline. - MPM.addPass(RequireAnalysisPass()); - - // Begin a postorder CGSCC pipeline to clean up and perform function inlining - // after Tapir lowering. - InlineParams IP = getInlineParamsFromOptLevel(OptimizationLevel::O0); - ModuleInlinerWrapperPass PostLowerMIWP(IP, DebugLogging, - PerformMandatoryInliningsFirst, - UseInlineAdvisor, MaxDevirtIterations); + MPM.addPass(AlwaysInlinerPass( + /*InsertLifetimeIntrinsics=*/PTO.Coroutines)); // Require the GlobalsAA analysis for the module so we can query it within // the CGSCC pipeline. - PostLowerMIWP.addRequiredModuleAnalysis(); - - // Require the ProfileSummaryAnalysis for the module so we can query it within - // the inliner pass. - PostLowerMIWP.addRequiredModuleAnalysis(); + MPM.addPass(RequireAnalysisPass()); - // Now begin the postoder CGSCC pipeline. - CGSCCPassManager &PostLowerCGPipeline = PostLowerMIWP.getPM(); + // Begin the postoder CGSCC pipeline. + CGSCCPassManager PostLowerCGPipeline(DebugLogging); // Now deduce any function attributes based in the current code. PostLowerCGPipeline.addPass(PostOrderFunctionAttrsPass()); @@ -1670,6 +1659,11 @@ PassBuilder::buildTapirLoweringPipeline(OptimizationLevel Level, // Drop bodies of available eternally objects to improve GlobalDCE. MPM.addPass(EliminateAvailableExternallyPass()); + // Do RPO function attribute inference across the module to forward-propagate + // attributes where applicable. + // FIXME: Is this really an optimization rather than a canonicalization? + MPM.addPass(ReversePostOrderFunctionAttrsPass()); + // Now that we have optimized the program, discard unreachable functions. MPM.addPass(GlobalDCEPass()); diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 0f84ecde0b15d..971a79b41cab9 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -1060,6 +1060,7 @@ void PassManagerBuilder::populateModulePassManager( // rotated form due to GVN or other transformations, and loop spawning // relies on the rotated form. Disable header duplication at -Oz. MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1)); + MPM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap)); // Outline Tapir loops as needed. MPM.add(createLoopSpawningTIPass()); if (VerifyTapir)