@@ -419,14 +419,16 @@ static bool isLTOPostLink(ThinOrFullLTOPhase Phase) {
419419
420420// Helper to wrap conditionally Coro passes.
421421static CoroConditionalWrapper buildCoroWrapper (ThinOrFullLTOPhase Phase) {
422- // TODO: Skip passes according to Phase.
423422 ModulePassManager CoroPM;
424- CoroPM.addPass (CoroEarlyPass ());
425- CGSCCPassManager CGPM;
426- CGPM.addPass (CoroSplitPass ());
427- CoroPM.addPass (createModuleToPostOrderCGSCCPassAdaptor (std::move (CGPM)));
428- CoroPM.addPass (CoroCleanupPass ());
429- CoroPM.addPass (GlobalDCEPass ());
423+ if (!isLTOPostLink (Phase))
424+ CoroPM.addPass (CoroEarlyPass ());
425+ if (!isLTOPreLink (Phase)) {
426+ CGSCCPassManager CGPM;
427+ CGPM.addPass (CoroSplitPass ());
428+ CoroPM.addPass (createModuleToPostOrderCGSCCPassAdaptor (std::move (CGPM)));
429+ CoroPM.addPass (CoroCleanupPass ());
430+ CoroPM.addPass (GlobalDCEPass ());
431+ }
430432 return CoroConditionalWrapper (std::move (CoroPM));
431433}
432434
@@ -1010,7 +1012,7 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level,
10101012 MainCGPipeline.addPass (createCGSCCToFunctionPassAdaptor (
10111013 RequireAnalysisPass<ShouldNotRunFunctionPassesAnalysis, Function>()));
10121014
1013- if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink ) {
1015+ if (! isLTOPreLink (Phase) ) {
10141016 MainCGPipeline.addPass (CoroSplitPass (Level != OptimizationLevel::O0));
10151017 MainCGPipeline.addPass (CoroAnnotationElidePass ());
10161018 }
@@ -1060,7 +1062,7 @@ PassBuilder::buildModuleInlinerPipeline(OptimizationLevel Level,
10601062 buildFunctionSimplificationPipeline (Level, Phase),
10611063 PTO.EagerlyInvalidateAnalyses ));
10621064
1063- if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink ) {
1065+ if (! isLTOPreLink (Phase) ) {
10641066 MPM.addPass (createModuleToPostOrderCGSCCPassAdaptor (
10651067 CoroSplitPass (Level != OptimizationLevel::O0)));
10661068 MPM.addPass (
@@ -1120,7 +1122,8 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
11201122 // Do basic inference of function attributes from known properties of system
11211123 // libraries and other oracles.
11221124 MPM.addPass (InferFunctionAttrsPass ());
1123- MPM.addPass (CoroEarlyPass ());
1125+ if (!isLTOPostLink (Phase))
1126+ MPM.addPass (CoroEarlyPass ());
11241127
11251128 FunctionPassManager EarlyFPM;
11261129 EarlyFPM.addPass (EntryExitInstrumenterPass (/* PostInlining=*/ false ));
@@ -1283,7 +1286,7 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
12831286 // and argument promotion.
12841287 MPM.addPass (DeadArgumentEliminationPass ());
12851288
1286- if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink )
1289+ if (! isLTOPreLink (Phase) )
12871290 MPM.addPass (CoroCleanupPass ());
12881291
12891292 // Optimize globals now that functions are fully simplified.
@@ -1948,9 +1951,6 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
19481951 return MPM;
19491952 }
19501953
1951- // TODO: Skip to match buildCoroWrapper.
1952- MPM.addPass (CoroEarlyPass ());
1953-
19541954 // Optimize globals to try and fold them into constants.
19551955 MPM.addPass (GlobalOptPass ());
19561956
0 commit comments