[PATCH] D96694: Use LoopRotate PrepareForLTO stage in NPM
Sanne Wouda via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 15 01:40:56 PST 2021
sanwou01 created this revision.
Herald added subscribers: hiraditya, inglorion.
sanwou01 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The PrepareForLTO stage of LoopRotate tries to avoid unrolling loops
with calls that might be inlined later. See D94232 <https://reviews.llvm.org/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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96694
Files:
llvm/lib/Passes/PassBuilder.cpp
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -516,6 +516,17 @@
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
+// Helper to check the current compilation phase
+static bool isLTOPreLink(ThinOrFullLTOPhase Phase) {
+ switch (Phase) {
+ case ThinOrFullLTOPhase::ThinLTOPreLink:
+ case ThinOrFullLTOPhase::FullLTOPreLink:
+ return true;
+ default:
+ return false;
+ }
+}
+
// TODO: Investigate the cost/benefit of tail call elimination on debugging.
FunctionPassManager
PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
@@ -562,7 +573,8 @@
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());
@@ -726,7 +738,8 @@
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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96694.323689.patch
Type: text/x-patch
Size: 1611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210215/47ffe6b5/attachment.bin>
More information about the llvm-commits
mailing list