@@ -365,9 +365,10 @@ void PassBuilder::invokeOptimizerEarlyEPCallbacks(ModulePassManager &MPM,
365365 C (MPM, Level);
366366}
367367void PassBuilder::invokeOptimizerLastEPCallbacks (ModulePassManager &MPM,
368- OptimizationLevel Level) {
368+ OptimizationLevel Level,
369+ ThinOrFullLTOPhase Phase) {
369370 for (auto &C : OptimizerLastEPCallbacks)
370- C (MPM, Level);
371+ C (MPM, Level, Phase );
371372}
372373void PassBuilder::invokeFullLinkTimeOptimizationEarlyEPCallbacks (
373374 ModulePassManager &MPM, OptimizationLevel Level) {
@@ -1527,7 +1528,7 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
15271528 MPM.addPass (createModuleToFunctionPassAdaptor (std::move (OptimizePM),
15281529 PTO.EagerlyInvalidateAnalyses ));
15291530
1530- invokeOptimizerLastEPCallbacks (MPM, Level);
1531+ invokeOptimizerLastEPCallbacks (MPM, Level, LTOPhase );
15311532
15321533 // Split out cold code. Splitting is done late to avoid hiding context from
15331534 // other optimizations and inadvertently regressing performance. The tradeoff
@@ -1569,9 +1570,9 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
15691570
15701571ModulePassManager
15711572PassBuilder::buildPerModuleDefaultPipeline (OptimizationLevel Level,
1572- bool LTOPreLink ) {
1573+ ThinOrFullLTOPhase Phase ) {
15731574 if (Level == OptimizationLevel::O0)
1574- return buildO0DefaultPipeline (Level, LTOPreLink );
1575+ return buildO0DefaultPipeline (Level, Phase );
15751576
15761577 ModulePassManager MPM;
15771578
@@ -1587,14 +1588,11 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
15871588 // Apply module pipeline start EP callback.
15881589 invokePipelineStartEPCallbacks (MPM, Level);
15891590
1590- const ThinOrFullLTOPhase LTOPhase = LTOPreLink
1591- ? ThinOrFullLTOPhase::FullLTOPreLink
1592- : ThinOrFullLTOPhase::None;
15931591 // Add the core simplification pipeline.
1594- MPM.addPass (buildModuleSimplificationPipeline (Level, LTOPhase ));
1592+ MPM.addPass (buildModuleSimplificationPipeline (Level, Phase ));
15951593
15961594 // Now add the optimization pipeline.
1597- MPM.addPass (buildModuleOptimizationPipeline (Level, LTOPhase ));
1595+ MPM.addPass (buildModuleOptimizationPipeline (Level, Phase ));
15981596
15991597 if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
16001598 PGOOpt->Action == PGOOptions::SampleUse)
@@ -1603,7 +1601,7 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
16031601 // Emit annotation remarks.
16041602 addAnnotationRemarksPass (MPM);
16051603
1606- if (LTOPreLink )
1604+ if (isLTOPreLink (Phase) )
16071605 addRequiredLTOPreLinkPasses (MPM);
16081606 return MPM;
16091607}
@@ -1634,7 +1632,7 @@ PassBuilder::buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO,
16341632ModulePassManager
16351633PassBuilder::buildThinLTOPreLinkDefaultPipeline (OptimizationLevel Level) {
16361634 if (Level == OptimizationLevel::O0)
1637- return buildO0DefaultPipeline (Level, /* LTOPreLink */ true );
1635+ return buildO0DefaultPipeline (Level, ThinOrFullLTOPhase::ThinLTOPreLink );
16381636
16391637 ModulePassManager MPM;
16401638
@@ -1674,7 +1672,8 @@ PassBuilder::buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level) {
16741672 // optimization is going to be done in PostLink stage, but clang can't add
16751673 // callbacks there in case of in-process ThinLTO called by linker.
16761674 invokeOptimizerEarlyEPCallbacks (MPM, Level);
1677- invokeOptimizerLastEPCallbacks (MPM, Level);
1675+ invokeOptimizerLastEPCallbacks (MPM, Level,
1676+ ThinOrFullLTOPhase::ThinLTOPreLink);
16781677
16791678 // Emit annotation remarks.
16801679 addAnnotationRemarksPass (MPM);
@@ -1743,7 +1742,7 @@ ModulePassManager
17431742PassBuilder::buildLTOPreLinkDefaultPipeline (OptimizationLevel Level) {
17441743 // FIXME: We should use a customized pre-link pipeline!
17451744 return buildPerModuleDefaultPipeline (Level,
1746- /* LTOPreLink */ true );
1745+ ThinOrFullLTOPhase::FullLTOPreLink );
17471746}
17481747
17491748ModulePassManager
@@ -2068,8 +2067,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
20682067 return MPM;
20692068}
20702069
2071- ModulePassManager PassBuilder::buildO0DefaultPipeline (OptimizationLevel Level,
2072- bool LTOPreLink) {
2070+ ModulePassManager
2071+ PassBuilder::buildO0DefaultPipeline (OptimizationLevel Level,
2072+ ThinOrFullLTOPhase Phase) {
20732073 assert (Level == OptimizationLevel::O0 &&
20742074 " buildO0DefaultPipeline should only be used with O0" );
20752075
@@ -2162,9 +2162,9 @@ ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
21622162 CoroPM.addPass (GlobalDCEPass ());
21632163 MPM.addPass (CoroConditionalWrapper (std::move (CoroPM)));
21642164
2165- invokeOptimizerLastEPCallbacks (MPM, Level);
2165+ invokeOptimizerLastEPCallbacks (MPM, Level, Phase );
21662166
2167- if (LTOPreLink )
2167+ if (isLTOPreLink (Phase) )
21682168 addRequiredLTOPreLinkPasses (MPM);
21692169
21702170 MPM.addPass (createModuleToFunctionPassAdaptor (AnnotationRemarksPass ()));
0 commit comments