|
25 | 25 | #include "llvm/Analysis/ScopedNoAliasAA.h" |
26 | 26 | #include "llvm/Analysis/TypeBasedAliasAnalysis.h" |
27 | 27 | #include "llvm/IR/PassManager.h" |
| 28 | +#include "llvm/Pass.h" |
28 | 29 | #include "llvm/Passes/OptimizationLevel.h" |
29 | 30 | #include "llvm/Passes/PassBuilder.h" |
30 | 31 | #include "llvm/Support/CommandLine.h" |
@@ -1014,6 +1015,11 @@ PassBuilder::buildModuleInlinerPipeline(OptimizationLevel Level, |
1014 | 1015 | IP.EnableDeferral = false; |
1015 | 1016 |
|
1016 | 1017 | MPM.addPass(ModuleInlinerPass(IP, UseInlineAdvisor, Phase)); |
| 1018 | + if (!UseCtxProfile.empty() && Phase == ThinOrFullLTOPhase::ThinLTOPostLink) { |
| 1019 | + MPM.addPass(GlobalOptPass()); |
| 1020 | + MPM.addPass(GlobalDCEPass()); |
| 1021 | + MPM.addPass(PGOCtxProfFlatteningPass()); |
| 1022 | + } |
1017 | 1023 |
|
1018 | 1024 | MPM.addPass(createModuleToFunctionPassAdaptor( |
1019 | 1025 | buildFunctionSimplificationPipeline(Level, Phase), |
@@ -1740,11 +1746,14 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline( |
1740 | 1746 | MPM.addPass(GlobalDCEPass()); |
1741 | 1747 | return MPM; |
1742 | 1748 | } |
1743 | | - |
1744 | | - // Add the core simplification pipeline. |
1745 | | - MPM.addPass(buildModuleSimplificationPipeline( |
1746 | | - Level, ThinOrFullLTOPhase::ThinLTOPostLink)); |
1747 | | - |
| 1749 | + if (!UseCtxProfile.empty()) { |
| 1750 | + MPM.addPass( |
| 1751 | + buildModuleInlinerPipeline(Level, ThinOrFullLTOPhase::ThinLTOPostLink)); |
| 1752 | + } else { |
| 1753 | + // Add the core simplification pipeline. |
| 1754 | + MPM.addPass(buildModuleSimplificationPipeline( |
| 1755 | + Level, ThinOrFullLTOPhase::ThinLTOPostLink)); |
| 1756 | + } |
1748 | 1757 | // Now add the optimization pipeline. |
1749 | 1758 | MPM.addPass(buildModuleOptimizationPipeline( |
1750 | 1759 | Level, ThinOrFullLTOPhase::ThinLTOPostLink)); |
|
0 commit comments