[NPM] Fix LoopNestPasses in -print-pipeline-passes
authorMarkus Lavin <markus.lavin@ericsson.com>
Wed, 1 Dec 2021 06:39:40 +0000 (07:39 +0100)
committerMarkus Lavin <markus.lavin@ericsson.com>
Wed, 1 Dec 2021 06:57:17 +0000 (07:57 +0100)
Fix printing of LoopNestPasses when using the opt pipeline printer
option -print-pipeline-passes.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D114771

llvm/lib/Transforms/Scalar/LoopPassManager.cpp
llvm/test/Other/new-pm-print-pipeline.ll

index 3df4cfe8e4c13ce7783c0a3c827cbbce72b492ca..6c783848432b44458234b0c832895a028cde9c43 100644 (file)
@@ -49,9 +49,17 @@ void PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
                  LPMUpdater &>::printPipeline(raw_ostream &OS,
                                               function_ref<StringRef(StringRef)>
                                                   MapClassName2PassName) {
-  for (unsigned Idx = 0, Size = LoopPasses.size(); Idx != Size; ++Idx) {
-    auto *P = LoopPasses[Idx].get();
-    P->printPipeline(OS, MapClassName2PassName);
+  assert(LoopPasses.size() + LoopNestPasses.size() == IsLoopNestPass.size());
+
+  unsigned IdxLP = 0, IdxLNP = 0;
+  for (unsigned Idx = 0, Size = IsLoopNestPass.size(); Idx != Size; ++Idx) {
+    if (IsLoopNestPass[Idx]) {
+      auto *P = LoopNestPasses[IdxLNP++].get();
+      P->printPipeline(OS, MapClassName2PassName);
+    } else {
+      auto *P = LoopPasses[IdxLP++].get();
+      P->printPipeline(OS, MapClassName2PassName);
+    }
     if (Idx + 1 < Size)
       OS << ",";
   }
index da06e93080512dcaa13eb4ebee55aa183b673afd..ac0a1a06b7e71c19fadd6d9f1d0c743d00af951a 100644 (file)
@@ -69,3 +69,7 @@
 
 ; 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
 ; CHECK-22: cgscc(function<eager-inv>(no-op-function)),function<eager-inv>(no-op-function)
+
+;; Test that the loop-nest-pass lnicm is printed with the other loop-passes in the pipeline.
+; 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
+; CHECK-23: function(loop-mssa(licm,loop-rotate,loop-deletion,lnicm,loop-rotate))