@@ -369,9 +369,10 @@ void PassBuilder::invokeOptimizerEarlyEPCallbacks(ModulePassManager &MPM,
369369 C (MPM, Level);
370370}
371371void PassBuilder::invokeOptimizerLastEPCallbacks (ModulePassManager &MPM,
372- OptimizationLevel Level) {
372+ OptimizationLevel Level,
373+ ThinOrFullLTOPhase Phase) {
373374 for (auto &C : OptimizerLastEPCallbacks)
374- C (MPM, Level);
375+ C (MPM, Level, Phase );
375376}
376377void PassBuilder::invokeFullLinkTimeOptimizationEarlyEPCallbacks (
377378 ModulePassManager &MPM, OptimizationLevel Level) {
@@ -1539,7 +1540,7 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
15391540 MPM.addPass (createModuleToFunctionPassAdaptor (std::move (OptimizePM),
15401541 PTO.EagerlyInvalidateAnalyses ));
15411542
1542- invokeOptimizerLastEPCallbacks (MPM, Level);
1543+ invokeOptimizerLastEPCallbacks (MPM, Level, LTOPhase );
15431544
15441545 // Split out cold code. Splitting is done late to avoid hiding context from
15451546 // other optimizations and inadvertently regressing performance. The tradeoff
@@ -1581,9 +1582,9 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
15811582
15821583ModulePassManager
15831584PassBuilder::buildPerModuleDefaultPipeline (OptimizationLevel Level,
1584- bool LTOPreLink ) {
1585+ ThinOrFullLTOPhase Phase ) {
15851586 if (Level == OptimizationLevel::O0)
1586- return buildO0DefaultPipeline (Level, LTOPreLink );
1587+ return buildO0DefaultPipeline (Level, Phase );
15871588
15881589 ModulePassManager MPM;
15891590
@@ -1599,14 +1600,11 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
15991600 // Apply module pipeline start EP callback.
16001601 invokePipelineStartEPCallbacks (MPM, Level);
16011602
1602- const ThinOrFullLTOPhase LTOPhase = LTOPreLink
1603- ? ThinOrFullLTOPhase::FullLTOPreLink
1604- : ThinOrFullLTOPhase::None;
16051603 // Add the core simplification pipeline.
1606- MPM.addPass (buildModuleSimplificationPipeline (Level, LTOPhase ));
1604+ MPM.addPass (buildModuleSimplificationPipeline (Level, Phase ));
16071605
16081606 // Now add the optimization pipeline.
1609- MPM.addPass (buildModuleOptimizationPipeline (Level, LTOPhase ));
1607+ MPM.addPass (buildModuleOptimizationPipeline (Level, Phase ));
16101608
16111609 if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
16121610 PGOOpt->Action == PGOOptions::SampleUse)
@@ -1615,7 +1613,7 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
16151613 // Emit annotation remarks.
16161614 addAnnotationRemarksPass (MPM);
16171615
1618- if (LTOPreLink )
1616+ if (isLTOPreLink (Phase) )
16191617 addRequiredLTOPreLinkPasses (MPM);
16201618 return MPM;
16211619}
@@ -1646,7 +1644,7 @@ PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
16461644ModulePassManager
16471645PassBuilder::buildThinLTOPreLinkDefaultPipeline (OptimizationLevel Level) {
16481646 if (Level == OptimizationLevel::O0)
1649- return buildO0DefaultPipeline (Level, /* LTOPreLink */ true );
1647+ return buildO0DefaultPipeline (Level, ThinOrFullLTOPhase::ThinLTOPreLink );
16501648
16511649 ModulePassManager MPM;
16521650
@@ -1691,7 +1689,8 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
16911689 // optimization is going to be done in PostLink stage, but clang can't add
16921690 // callbacks there in case of in-process ThinLTO called by linker.
16931691 invokeOptimizerEarlyEPCallbacks (MPM, Level);
1694- invokeOptimizerLastEPCallbacks (MPM, Level);
1692+ invokeOptimizerLastEPCallbacks (MPM, Level,
1693+ ThinOrFullLTOPhase::ThinLTOPreLink);
16951694
16961695 // Emit annotation remarks.
16971696 addAnnotationRemarksPass (MPM);
@@ -1760,7 +1759,7 @@ ModulePassManager
17601759PassBuilder::buildLTOPreLinkDefaultPipeline (OptimizationLevel Level) {
17611760 // FIXME: We should use a customized pre-link pipeline!
17621761 return buildPerModuleDefaultPipeline (Level,
1763- /* LTOPreLink */ true );
1762+ ThinOrFullLTOPhase::FullLTOPreLink );
17641763}
17651764
17661765ModulePassManager
@@ -2085,8 +2084,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
20852084 return MPM;
20862085}
20872086
2088- ModulePassManager PassBuilder::buildO0DefaultPipeline (OptimizationLevel Level,
2089- bool LTOPreLink) {
2087+ ModulePassManager
2088+ PassBuilder::buildO0DefaultPipeline (OptimizationLevel Level,
2089+ ThinOrFullLTOPhase Phase) {
20902090 assert (Level == OptimizationLevel::O0 &&
20912091 " buildO0DefaultPipeline should only be used with O0" );
20922092
@@ -2179,9 +2179,9 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
21792179 CoroPM.addPass (GlobalDCEPass ());
21802180 MPM.addPass (CoroConditionalWrapper (std::move (CoroPM)));
21812181
2182- invokeOptimizerLastEPCallbacks (MPM, Level);
2182+ invokeOptimizerLastEPCallbacks (MPM, Level, Phase );
21832183
2184- if (LTOPreLink )
2184+ if (isLTOPreLink (Phase) )
21852185 addRequiredLTOPreLinkPasses (MPM);
21862186
21872187 MPM.addPass (createModuleToFunctionPassAdaptor (AnnotationRemarksPass ()));
0 commit comments