Skip to content

Commit ce22b7f

Browse files
committed
[NPM] Fix LoopNestPasses in -print-pipeline-passes
Fix printing of LoopNestPasses when using the opt pipeline printer option -print-pipeline-passes. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D114771
1 parent 69a8a7c commit ce22b7f

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

llvm/lib/Transforms/Scalar/LoopPassManager.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,17 @@ void PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
4949
LPMUpdater &>::printPipeline(raw_ostream &OS,
5050
function_ref<StringRef(StringRef)>
5151
MapClassName2PassName) {
52-
for (unsigned Idx = 0, Size = LoopPasses.size(); Idx != Size; ++Idx) {
53-
auto *P = LoopPasses[Idx].get();
54-
P->printPipeline(OS, MapClassName2PassName);
52+
assert(LoopPasses.size() + LoopNestPasses.size() == IsLoopNestPass.size());
53+
54+
unsigned IdxLP = 0, IdxLNP = 0;
55+
for (unsigned Idx = 0, Size = IsLoopNestPass.size(); Idx != Size; ++Idx) {
56+
if (IsLoopNestPass[Idx]) {
57+
auto *P = LoopNestPasses[IdxLNP++].get();
58+
P->printPipeline(OS, MapClassName2PassName);
59+
} else {
60+
auto *P = LoopPasses[IdxLP++].get();
61+
P->printPipeline(OS, MapClassName2PassName);
62+
}
5563
if (Idx + 1 < Size)
5664
OS << ",";
5765
}

llvm/test/Other/new-pm-print-pipeline.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@
6969

7070
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='cgscc(function<eager-inv>(no-op-function)),function<eager-inv>(no-op-function)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-22
7171
; CHECK-22: cgscc(function<eager-inv>(no-op-function)),function<eager-inv>(no-op-function)
72+
73+
;; Test that the loop-nest-pass lnicm is printed with the other loop-passes in the pipeline.
74+
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='function(loop-mssa(licm,loop-rotate,loop-deletion,lnicm,loop-rotate))' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-23
75+
; CHECK-23: function(loop-mssa(licm,loop-rotate,loop-deletion,lnicm,loop-rotate))

0 commit comments

Comments
 (0)