[llvm] 93d9a4c - Use LoopRotate PrepareForLTO stage in NPM
Sanne Wouda via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 17 06:07:05 PST 2021
Author: Sanne Wouda
Date: 2021-02-17T14:06:57Z
New Revision: 93d9a4c95aff62bad9603029ee38faedfee40dea
URL: https://github.com/llvm/llvm-project/commit/93d9a4c95aff62bad9603029ee38faedfee40dea
DIFF: https://github.com/llvm/llvm-project/commit/93d9a4c95aff62bad9603029ee38faedfee40dea.diff
LOG: Use LoopRotate PrepareForLTO stage in NPM
The PrepareForLTO stage of LoopRotate tries to avoid unrolling loops
with calls that might be inlined later. See D94232 where this was
introduced.
We didn't catch all occurances of the LoopRotatePass in the New Pass
Manager, so the original regression in astar returned with the pass
manager switch.
Added:
Modified:
llvm/lib/Passes/PassBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index f0e9f475b9d6..6f35e567a14d 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -517,6 +517,12 @@ static void addAnnotationRemarksPass(ModulePassManager &MPM) {
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
+// Helper to check if the current compilation phase is preparing for LTO
+static bool isLTOPreLink(ThinOrFullLTOPhase Phase) {
+ return Phase == ThinOrFullLTOPhase::ThinLTOPreLink ||
+ Phase == ThinOrFullLTOPhase::ThinLTOPreLink;
+}
+
// TODO: Investigate the cost/benefit of tail call elimination on debugging.
FunctionPassManager
PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
@@ -563,7 +569,8 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
LPM1.addPass(LoopInstSimplifyPass());
LPM1.addPass(LoopSimplifyCFGPass());
- LPM1.addPass(LoopRotatePass(/* Disable header duplication */ true));
+ LPM1.addPass(LoopRotatePass(/* Disable header duplication */ true,
+ isLTOPreLink(Phase)));
// TODO: Investigate promotion cap for O1.
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
LPM1.addPass(SimpleLoopUnswitchPass());
@@ -727,7 +734,8 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
LPM1.addPass(LoopSimplifyCFGPass());
// Disable header duplication in loop rotation at -Oz.
- LPM1.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
+ LPM1.addPass(
+ LoopRotatePass(Level != OptimizationLevel::Oz, isLTOPreLink(Phase)));
// TODO: Investigate promotion cap for O1.
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
LPM1.addPass(
More information about the llvm-commits
mailing list