[clang] 0c509db - [NewPM] Add options to PrintPassInstrumentation

Arthur Eubanks via cfe-commits cfe-commits at lists.llvm.org
Tue May 18 20:59:58 PDT 2021


Author: Arthur Eubanks
Date: 2021-05-18T20:59:35-07:00
New Revision: 0c509dbc7e29cbd03f161513b8d335f768c7cc2b

URL: https://github.com/llvm/llvm-project/commit/0c509dbc7e29cbd03f161513b8d335f768c7cc2b
DIFF: https://github.com/llvm/llvm-project/commit/0c509dbc7e29cbd03f161513b8d335f768c7cc2b.diff

LOG: [NewPM] Add options to PrintPassInstrumentation

To bring D99599's implementation in line with the existing
PrintPassInstrumentation, and to fix a FIXME, add more customizability
to PrintPassInstrumentation.

Introduce three new options. The first takes over the existing
"-debug-pass-manager-verbose" cl::opt.

The second and third option are specific to -fdebug-pass-structure. They
allow indentation, and also don't print analysis queries.

To avoid more golden file tests than necessary, prune down the
-fdebug-pass-structure tests.

Reviewed By: asbirlea

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

Added: 
    

Modified: 
    clang/lib/CodeGen/BackendUtil.cpp
    clang/test/Driver/debug-pass-structure.c
    llvm/include/llvm/Passes/StandardInstrumentations.h
    llvm/lib/Passes/StandardInstrumentations.cpp
    llvm/test/Other/new-pass-manager-cgscc-fct-proxy.ll
    llvm/test/Other/opt-O3-pipeline.ll
    llvm/test/Other/pass-pipeline-parsing.ll
    llvm/tools/opt/NewPMDriver.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 989210ca5390..c0b29a85504d 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -873,10 +873,6 @@ static void setCommandLineOpts(const CodeGenOptions &CodeGenOpts) {
   if (!CodeGenOpts.DebugPass.empty()) {
     BackendArgs.push_back("-debug-pass");
     BackendArgs.push_back(CodeGenOpts.DebugPass.c_str());
-    // New PM supports structure dumping. Old PM is still used for codegen,
-    // so we need to pass both options.
-    if (!CodeGenOpts.LegacyPassManager && CodeGenOpts.DebugPass == "Structure")
-      BackendArgs.push_back("-debug-pass-structure");
   }
   if (!CodeGenOpts.LimitFloatPrecision.empty()) {
     BackendArgs.push_back("-limit-float-precision");
@@ -1284,8 +1280,14 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   CGSCCAnalysisManager CGAM;
   ModuleAnalysisManager MAM;
 
+  bool DebugPassStructure = CodeGenOpts.DebugPass == "Structure";
   PassInstrumentationCallbacks PIC;
-  StandardInstrumentations SI(CodeGenOpts.DebugPassManager);
+  PrintPassOptions PrintPassOpts;
+  PrintPassOpts.Indent = DebugPassStructure;
+  PrintPassOpts.SkipAnalyses = DebugPassStructure;
+  StandardInstrumentations SI(CodeGenOpts.DebugPassManager ||
+                                  DebugPassStructure,
+                              /*VerifyEach*/ false, PrintPassOpts);
   SI.registerCallbacks(PIC, &FAM);
   PassBuilder PB(TM.get(), PTO, PGOOpt, &PIC);
 

diff  --git a/clang/test/Driver/debug-pass-structure.c b/clang/test/Driver/debug-pass-structure.c
index ca22e69baf07..5fde11e4d80d 100644
--- a/clang/test/Driver/debug-pass-structure.c
+++ b/clang/test/Driver/debug-pass-structure.c
@@ -1,44 +1,15 @@
 // Test that we print pass structure with new and legacy PM.
-// RUN: %clang -fexperimental-new-pass-manager -fdebug-pass-structure -fintegrated-as -O3 -S -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=NEWPM
+// RUN: %clang -fexperimental-new-pass-manager -fdebug-pass-structure -fintegrated-as -O3 -S -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=NEWPM --strict-whitespace
 // RUN: %clang -flegacy-pass-manager -fdebug-pass-structure -O0 -S -emit-llvm %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=LEGACYPM
 // REQUIRES: asserts
 
-// NEWPM: Annotation2MetadataPass on [module]
-// NEWPM-NEXT: ForceFunctionAttrsPass on [module]
-// NEWPM-NEXT: InferFunctionAttrsPass on [module]
-// NEWPM-NEXT:   InnerAnalysisManagerProxy<{{.*}}> analysis on [module]
-// NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-// NEWPM-NEXT: OpenMPOptPass on [module]
-// NEWPM-NEXT: IPSCCPPass on [module]
-// NEWPM-NEXT: CalledValuePropagationPass on [module]
-// NEWPM-NEXT: GlobalOptPass on [module]
-// NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-// NEWPM-NEXT: DeadArgumentEliminationPass on [module]
-// NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-// NEWPM-NEXT: ModuleInlinerWrapperPass on [module]
-// NEWPM-NEXT:   InlineAdvisorAnalysis analysis on [module]
-// NEWPM-NEXT:   RequireAnalysisPass<{{.*}}> on [module]
-// NEWPM-NEXT:     GlobalsAA analysis on [module]
-// NEWPM-NEXT:       CallGraphAnalysis analysis on [module]
-// NEWPM-NEXT:   ModuleToFunctionPassAdaptor on [module]
-// NEWPM-NEXT:   RequireAnalysisPass<{{.*}}> on [module]
-// NEWPM-NEXT:     ProfileSummaryAnalysis analysis on [module]
-// NEWPM-NEXT:   ModuleToPostOrderCGSCCPassAdaptor on [module]
-// NEWPM-NEXT:     InnerAnalysisManagerProxy<{{.*}}> analysis on [module]
-// NEWPM-NEXT:       LazyCallGraphAnalysis analysis on [module]
-// NEWPM-NEXT: GlobalOptPass on [module]
-// NEWPM-NEXT: GlobalDCEPass on [module]
-// NEWPM-NEXT: EliminateAvailableExternallyPass on [module]
-// NEWPM-NEXT: ReversePostOrderFunctionAttrsPass on [module]
-// NEWPM-NEXT: RequireAnalysisPass<{{.*}}> on [module]
-// NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-// CGProfilePass is disabled with non-integrated assemblers
-// NEWPM-NEXT: CGProfilePass on [module]
-// NEWPM-NEXT: GlobalDCEPass on [module]
-// NEWPM-NEXT: ConstantMergePass on [module]
-// NEWPM-NEXT: RelLookupTableConverterPass on [module]
-// NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-// NEWPM-NEXT: PrintModulePass on [module]
+// should have proper indentation, should not print any analysis information
+// NEWPM-NOT: Running analysis
+// NEWPM: {{^}}Running{{.*}}GlobalOptPass
+// NEWPM: {{^}}  Running{{.*}}RequireAnalysisPass{{.*}}GlobalsAA
+// NEWPM: GlobalOptPass
+// NEWPM-NOT: Invalidating analysis
 
-// LEGACYPM:      Pass Arguments:
+// LEGACYPM: Pass Arguments:
 
+void f() {}

diff  --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 6b29bd66278f..5fadb6f717ad 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -80,27 +80,28 @@ class OptBisectInstrumentation {
   void registerCallbacks(PassInstrumentationCallbacks &PIC);
 };
 
+struct PrintPassOptions {
+  /// Print adaptors and pass managers.
+  bool Verbose = false;
+  /// Don't print information for analyses.
+  bool SkipAnalyses = false;
+  /// Indent based on hierarchy.
+  bool Indent = false;
+};
+
 // Debug logging for transformation and analysis passes.
 class PrintPassInstrumentation {
-  void printWithIdent(bool Expand, const Twine &Msg);
+  raw_ostream &print();
 
 public:
-  PrintPassInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
+  PrintPassInstrumentation(bool Enabled, PrintPassOptions Opts)
+      : Enabled(Enabled), Opts(Opts) {}
   void registerCallbacks(PassInstrumentationCallbacks &PIC);
 
 private:
-  bool DebugLogging;
-  int Ident = 0;
-};
-
-// Pass structure dumper
-class PassStructurePrinter {
-  int Ident = 0;
-  void printWithIdent(bool Expand, const Twine &Msg);
-
-public:
-  PassStructurePrinter() {}
-  void registerCallbacks(PassInstrumentationCallbacks &PIC);
+  bool Enabled;
+  PrintPassOptions Opts;
+  int Indent = 0;
 };
 
 class PreservedCFGCheckerInstrumentation {
@@ -414,7 +415,6 @@ class VerifyInstrumentation {
 class StandardInstrumentations {
   PrintIRInstrumentation PrintIR;
   PrintPassInstrumentation PrintPass;
-  PassStructurePrinter StructurePrinter;
   TimePassesHandler TimePasses;
   OptNoneInstrumentation OptNone;
   OptBisectInstrumentation OptBisect;
@@ -427,7 +427,8 @@ class StandardInstrumentations {
   bool VerifyEach;
 
 public:
-  StandardInstrumentations(bool DebugLogging, bool VerifyEach = false);
+  StandardInstrumentations(bool DebugLogging, bool VerifyEach = false,
+                           PrintPassOptions PrintPassOpts = PrintPassOptions());
 
   // Register all the standard instrumentation callbacks. If \p FAM is nullptr
   // then PreservedCFGChecker is not enabled.

diff  --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index ae9b8a83157d..0410fdbccc0c 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -45,17 +45,6 @@ cl::opt<bool> PreservedCFGCheckerInstrumentation::VerifyPreservedCFG(
     cl::init(true));
 #endif
 
-// FIXME: Change `-debug-pass-manager` from boolean to enum type. Similar to
-// `-debug-pass` in legacy PM.
-static cl::opt<bool>
-    DebugPMVerbose("debug-pass-manager-verbose", cl::Hidden, cl::init(false),
-                   cl::desc("Print all pass management debugging information. "
-                            "`-debug-pass-manager` must also be specified"));
-
-static cl::opt<bool>
-    DebugPassStructure("debug-pass-structure", cl::Hidden, cl::init(false),
-                       cl::desc("Print pass structure information."));
-
 // An option that prints out the IR after passes, similar to
 // -print-after-all except that it only prints the IR after passes that
 // change the IR.  Those passes that do not make changes to the IR are
@@ -871,77 +860,73 @@ void OptBisectInstrumentation::registerCallbacks(
   });
 }
 
+raw_ostream &PrintPassInstrumentation::print() {
+  if (Opts.Indent) {
+    assert(Indent >= 0);
+    dbgs().indent(Indent);
+  }
+  return dbgs();
+}
+
 void PrintPassInstrumentation::registerCallbacks(
     PassInstrumentationCallbacks &PIC) {
-  if (!DebugLogging)
+  if (!Enabled)
     return;
 
   std::vector<StringRef> SpecialPasses;
-  if (!DebugPMVerbose) {
+  if (!Opts.Verbose) {
     SpecialPasses.emplace_back("PassManager");
     SpecialPasses.emplace_back("PassAdaptor");
   }
 
   PIC.registerBeforeSkippedPassCallback(
-      [SpecialPasses](StringRef PassID, Any IR) {
+      [this, SpecialPasses](StringRef PassID, Any IR) {
         assert(!isSpecialPass(PassID, SpecialPasses) &&
                "Unexpectedly skipping special pass");
 
-        dbgs() << "Skipping pass: " << PassID << " on " << getIRName(IR)
-               << "\n";
+        print() << "Skipping pass: " << PassID << " on " << getIRName(IR)
+                << "\n";
       });
+  PIC.registerBeforeNonSkippedPassCallback([this, SpecialPasses](
+                                               StringRef PassID, Any IR) {
+    if (isSpecialPass(PassID, SpecialPasses))
+      return;
 
-  PIC.registerBeforeNonSkippedPassCallback(
-      [SpecialPasses](StringRef PassID, Any IR) {
+    print() << "Running pass: " << PassID << " on " << getIRName(IR) << "\n";
+    Indent += 2;
+  });
+  PIC.registerAfterPassCallback(
+      [this, SpecialPasses](StringRef PassID, Any IR,
+                            const PreservedAnalyses &) {
         if (isSpecialPass(PassID, SpecialPasses))
           return;
 
-        dbgs() << "Running pass: " << PassID << " on " << getIRName(IR) << "\n";
-      });
-
-  PIC.registerBeforeAnalysisCallback([](StringRef PassID, Any IR) {
-    dbgs() << "Running analysis: " << PassID << " on " << getIRName(IR) << "\n";
-  });
-
-  PIC.registerAnalysisInvalidatedCallback([](StringRef PassID, Any IR) {
-    dbgs() << "Invalidating analysis: " << PassID << " on " << getIRName(IR)
-           << "\n";
-  });
-  PIC.registerAnalysesClearedCallback([](StringRef IRName) {
-    dbgs() << "Clearing all analysis results for: " << IRName << "\n";
-  });
-}
-
-void PassStructurePrinter::printWithIdent(bool Expand, const Twine &Msg) {
-  if (!Msg.isTriviallyEmpty())
-    dbgs().indent(Ident) << Msg << "\n";
-  Ident = Expand ? Ident + 2 : Ident - 2;
-  assert(Ident >= 0);
-}
-
-void PassStructurePrinter::registerCallbacks(
-    PassInstrumentationCallbacks &PIC) {
-  if (!DebugPassStructure)
-    return;
-
-  PIC.registerBeforeNonSkippedPassCallback([this](StringRef PassID, Any IR) {
-    printWithIdent(true, PassID + " on " + getIRName(IR));
-  });
-  PIC.registerAfterPassCallback(
-      [this](StringRef PassID, Any IR, const PreservedAnalyses &) {
-        printWithIdent(false, Twine());
+        Indent -= 2;
       });
-
   PIC.registerAfterPassInvalidatedCallback(
-      [this](StringRef PassID, const PreservedAnalyses &) {
-        printWithIdent(false, Twine());
+      [this, SpecialPasses](StringRef PassID, Any IR) {
+        if (isSpecialPass(PassID, SpecialPasses))
+          return;
+
+        Indent -= 2;
       });
 
-  PIC.registerBeforeAnalysisCallback([this](StringRef PassID, Any IR) {
-    printWithIdent(true, PassID + " analysis on " + getIRName(IR));
-  });
-  PIC.registerAfterAnalysisCallback(
-      [this](StringRef PassID, Any IR) { printWithIdent(false, Twine()); });
+  if (!Opts.SkipAnalyses) {
+    PIC.registerBeforeAnalysisCallback([this](StringRef PassID, Any IR) {
+      print() << "Running analysis: " << PassID << " on " << getIRName(IR)
+              << "\n";
+      Indent += 2;
+    });
+    PIC.registerAfterAnalysisCallback(
+        [this](StringRef PassID, Any IR) { Indent -= 2; });
+    PIC.registerAnalysisInvalidatedCallback([this](StringRef PassID, Any IR) {
+      print() << "Invalidating analysis: " << PassID << " on " << getIRName(IR)
+              << "\n";
+    });
+    PIC.registerAnalysesClearedCallback([this](StringRef IRName) {
+      print() << "Clearing all analysis results for: " << IRName << "\n";
+    });
+  }
 }
 
 PreservedCFGCheckerInstrumentation::CFG::CFG(const Function *F,
@@ -1227,9 +1212,9 @@ void InLineChangePrinter::registerCallbacks(PassInstrumentationCallbacks &PIC) {
     TextChangeReporter<ChangedIRData>::registerRequiredCallbacks(PIC);
 }
 
-StandardInstrumentations::StandardInstrumentations(bool DebugLogging,
-                                                   bool VerifyEach)
-    : PrintPass(DebugLogging), OptNone(DebugLogging),
+StandardInstrumentations::StandardInstrumentations(
+    bool DebugLogging, bool VerifyEach, PrintPassOptions PrintPassOpts)
+    : PrintPass(DebugLogging, PrintPassOpts), OptNone(DebugLogging),
       PrintChangedIR(PrintChanged == ChangePrinter::PrintChangedVerbose),
       PrintChangedDiff(
           PrintChanged == ChangePrinter::PrintChangedDiffVerbose ||
@@ -1242,7 +1227,6 @@ void StandardInstrumentations::registerCallbacks(
     PassInstrumentationCallbacks &PIC, FunctionAnalysisManager *FAM) {
   PrintIR.registerCallbacks(PIC);
   PrintPass.registerCallbacks(PIC);
-  StructurePrinter.registerCallbacks(PIC);
   TimePasses.registerCallbacks(PIC);
   OptNone.registerCallbacks(PIC);
   OptBisect.registerCallbacks(PIC);

diff  --git a/llvm/test/Other/new-pass-manager-cgscc-fct-proxy.ll b/llvm/test/Other/new-pass-manager-cgscc-fct-proxy.ll
index 278d470baf51..90f23faefdfe 100644
--- a/llvm/test/Other/new-pass-manager-cgscc-fct-proxy.ll
+++ b/llvm/test/Other/new-pass-manager-cgscc-fct-proxy.ll
@@ -1,6 +1,6 @@
-; RUN: opt %s -disable-verify -disable-output -passes='default<O2>' -debug-pass-manager -debug-pass-manager-verbose -cgscc-npm-no-fp-rerun=1 \
+; RUN: opt %s -disable-verify -disable-output -passes='default<O2>' -debug-pass-manager=verbose -cgscc-npm-no-fp-rerun=1 \
 ; RUN:  2>&1 | FileCheck %s -check-prefixes=CHECK,NOREPS
-; RUN: opt %s -disable-verify -disable-output -passes='default<O2>' -debug-pass-manager -debug-pass-manager-verbose -cgscc-npm-no-fp-rerun=0 \
+; RUN: opt %s -disable-verify -disable-output -passes='default<O2>' -debug-pass-manager=verbose -cgscc-npm-no-fp-rerun=0 \
 ; RUN:  2>&1 | FileCheck %s -check-prefixes=CHECK,REPS
 
 ; Pre-attribute the functions to avoid the PostOrderFunctionAttrsPass cause

diff  --git a/llvm/test/Other/opt-O3-pipeline.ll b/llvm/test/Other/opt-O3-pipeline.ll
index a97f28231ab1..af77e09c2496 100644
--- a/llvm/test/Other/opt-O3-pipeline.ll
+++ b/llvm/test/Other/opt-O3-pipeline.ll
@@ -1,5 +1,4 @@
 ; RUN: opt -enable-new-pm=0 -mtriple=x86_64-- -O3 -debug-pass=Structure < %s -o /dev/null 2>&1 | FileCheck --check-prefixes=CHECK,%llvmcheckext %s
-; RUN: opt -enable-new-pm=1 -mtriple=x86_64-- -O3 -debug-pass-structure < %s -o /dev/null 2>&1 | FileCheck --check-prefixes=NEWPM,%llvmcheckext %s
 
 ; REQUIRES: asserts
 
@@ -336,169 +335,6 @@
 ; CHECK-NEXT:     Branch Probability Analysis
 ; CHECK-NEXT:     Block Frequency Analysis
 
-; NEWPM:      VerifierPass on [module]
-; NEWPM-NEXT:   VerifierAnalysis analysis on [module]
-; NEWPM-NEXT: Annotation2MetadataPass on [module]
-; NEWPM-NEXT: ForceFunctionAttrsPass on [module]
-; NEWPM-NEXT: InferFunctionAttrsPass on [module]
-; NEWPM-NEXT:   InnerAnalysisManagerProxy<{{.*}}> analysis on [module]
-; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   PassManager<{{.*}}> on f
-; NEWPM-NEXT:     PreservedCFGCheckerAnalysis analysis on f
-; NEWPM-NEXT:     LowerExpectIntrinsicPass on f
-; NEWPM-NEXT:     SimplifyCFGPass on f
-; NEWPM-NEXT:       TargetIRAnalysis analysis on f
-; NEWPM-NEXT:       AssumptionAnalysis analysis on f
-; NEWPM-NEXT:     SROA on f
-; NEWPM-NEXT:       DominatorTreeAnalysis analysis on f
-; NEWPM-NEXT:     EarlyCSEPass on f
-; NEWPM-NEXT:       TargetLibraryAnalysis analysis on f
-; NEWPM-NEXT:     CallSiteSplittingPass on f
-; NEWPM-NEXT: OpenMPOptPass on [module]
-; NEWPM-NEXT: IPSCCPPass on [module]
-; NEWPM-NEXT: CalledValuePropagationPass on [module]
-; NEWPM-NEXT: GlobalOptPass on [module]
-; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   InnerAnalysisManagerProxy<{{.*}}> analysis on [module]
-; NEWPM-NEXT:   PromotePass on f
-; NEWPM-NEXT:     PreservedCFGCheckerAnalysis analysis on f
-; NEWPM-NEXT:     DominatorTreeAnalysis analysis on f
-; NEWPM-NEXT:     AssumptionAnalysis analysis on f
-; NEWPM-NEXT: DeadArgumentEliminationPass on [module]
-; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   PassManager<{{.*}}> on f
-; NEWPM-NEXT:     InstCombinePass on f
-; NEWPM-NEXT:       TargetLibraryAnalysis analysis on f
-; NEWPM-NEXT:       OptimizationRemarkEmitterAnalysis analysis on f
-; NEWPM-NEXT:       TargetIRAnalysis analysis on f
-; NEWPM-NEXT:       AAManager analysis on f
-; NEWPM-NEXT:         BasicAA analysis on f
-; NEWPM-NEXT:       OuterAnalysisManagerProxy<{{.*}}> analysis on f
-; NEWPM-NEXT:     SimplifyCFGPass on f
-; NEWPM-NEXT: ModuleInlinerWrapperPass on [module]
-; NEWPM-NEXT:   InlineAdvisorAnalysis analysis on [module]
-; NEWPM-NEXT:   RequireAnalysisPass<{{.*}}> on [module]
-; NEWPM-NEXT:     GlobalsAA analysis on [module]
-; NEWPM-NEXT:       CallGraphAnalysis analysis on [module]
-; NEWPM-NEXT:   ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   InvalidateAnalysisPass<{{.*}}> on f
-; NEWPM-NEXT:   RequireAnalysisPass<{{.*}}> on [module]
-; NEWPM-NEXT:     ProfileSummaryAnalysis analysis on [module]
-; NEWPM-NEXT:   ModuleToPostOrderCGSCCPassAdaptor on [module]
-; NEWPM-NEXT:     InnerAnalysisManagerProxy<{{.*}}> analysis on [module]
-; NEWPM-NEXT:       LazyCallGraphAnalysis analysis on [module]
-; NEWPM-NEXT:     FunctionAnalysisManagerCGSCCProxy analysis on (f)
-; NEWPM-NEXT:       OuterAnalysisManagerProxy<{{.*}}> analysis on (f)
-; NEWPM-NEXT:     DevirtSCCRepeatedPass on (f)
-; NEWPM-NEXT:       PassManager<{{.*}}> on (f)
-; NEWPM-NEXT:         InlinerPass on (f)
-; NEWPM-NEXT:         InlinerPass on (f)
-; NEWPM-NEXT:         PostOrderFunctionAttrsPass on (f)
-; NEWPM-NEXT:           AAManager analysis on f
-; NEWPM-NEXT:         ArgumentPromotionPass on (f)
-; NEWPM-NEXT:         OpenMPOptCGSCCPass on (f)
-; NEWPM-NEXT:         CGSCCToFunctionPassAdaptor on (f)
-; NEWPM-NEXT:           PassManager<{{.*}}> on f
-; NEWPM-NEXT:             SROA on f
-; NEWPM-NEXT:             EarlyCSEPass on f
-; NEWPM-NEXT:               MemorySSAAnalysis analysis on f
-; NEWPM-NEXT:             SpeculativeExecutionPass on f
-; NEWPM-NEXT:             JumpThreadingPass on f
-; NEWPM-NEXT:               LazyValueAnalysis analysis on f
-; NEWPM-NEXT:             CorrelatedValuePropagationPass on f
-; NEWPM-NEXT:             SimplifyCFGPass on f
-; NEWPM-NEXT:             AggressiveInstCombinePass on f
-; NEWPM-NEXT:             InstCombinePass on f
-; NEWPM-NEXT:             LibCallsShrinkWrapPass on f
-; NEWPM-NEXT:             TailCallElimPass on f
-; NEWPM-NEXT:             SimplifyCFGPass on f
-; NEWPM-NEXT:             ReassociatePass on f
-; NEWPM-NEXT:             RequireAnalysisPass<{{.*}}> on f
-; NEWPM-NEXT:             FunctionToLoopPassAdaptor on f
-; NEWPM-NEXT:               PassManager<{{.*}}> on f
-; NEWPM-NEXT:                 LoopSimplifyPass on f
-; NEWPM-NEXT:                   LoopAnalysis analysis on f
-; NEWPM-NEXT:                 LCSSAPass on f
-; NEWPM-NEXT:             SimplifyCFGPass on f
-; NEWPM-NEXT:             InstCombinePass on f
-; NEWPM-NEXT:             FunctionToLoopPassAdaptor on f
-; NEWPM-NEXT:               PassManager<{{.*}}> on f
-; NEWPM-NEXT:                 LoopSimplifyPass on f
-; NEWPM-NEXT:                 LCSSAPass on f
-; NEWPM-NEXT:             SROA on f
-; NEWPM-NEXT:             MergedLoadStoreMotionPass on f
-; NEWPM-NEXT:             GVN on f
-; NEWPM-NEXT:               MemoryDependenceAnalysis analysis on f
-; NEWPM-NEXT:                 PhiValuesAnalysis analysis on f
-; NEWPM-NEXT:             SCCPPass on f
-; NEWPM-NEXT:             BDCEPass on f
-; NEWPM-NEXT:               DemandedBitsAnalysis analysis on f
-; NEWPM-NEXT:             InstCombinePass on f
-; NEWPM-NEXT:             JumpThreadingPass on f
-; NEWPM-NEXT:               LazyValueAnalysis analysis on f
-; NEWPM-NEXT:             CorrelatedValuePropagationPass on f
-; NEWPM-NEXT:             ADCEPass on f
-; NEWPM-NEXT:               PostDominatorTreeAnalysis analysis on f
-; NEWPM-NEXT:             MemCpyOptPass on f
-; NEWPM-NEXT:             DSEPass on f
-; NEWPM-NEXT:             FunctionToLoopPassAdaptor on f
-; NEWPM-NEXT:               PassManager<{{.*}}> on f
-; NEWPM-NEXT:                 LoopSimplifyPass on f
-; NEWPM-NEXT:                 LCSSAPass on f
-; NEWPM-NEXT:             SimplifyCFGPass on f
-; NEWPM-NEXT:             InstCombinePass on f
-; NEWPM-NEXT: GlobalOptPass on [module]
-; NEWPM-NEXT: GlobalDCEPass on [module]
-; NEWPM-NEXT: EliminateAvailableExternallyPass on [module]
-; NEWPM-NEXT: ReversePostOrderFunctionAttrsPass on [module]
-; NEWPM-NEXT:   CallGraphAnalysis analysis on [module]
-; NEWPM-NEXT: RequireAnalysisPass<{{.*}}> on [module]
-; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   PassManager<{{.*}}> on f
-; NEWPM-NEXT:     Float2IntPass on f
-; NEWPM-NEXT:     LowerConstantIntrinsicsPass on f
-; NEWPM-NEXT:     FunctionToLoopPassAdaptor on f
-; NEWPM-NEXT:       PassManager<{{.*}}> on f
-; NEWPM-NEXT:         LoopSimplifyPass on f
-; NEWPM-NEXT:         LCSSAPass on f
-; NEWPM-NEXT:     LoopDistributePass on f
-; NEWPM-NEXT:       ScalarEvolutionAnalysis analysis on f
-; NEWPM-NEXT:       InnerAnalysisManagerProxy<{{.*}}> analysis on f
-; NEWPM-NEXT:     InjectTLIMappings on f
-; NEWPM-NEXT:     LoopVectorizePass on f
-; NEWPM-NEXT:       BlockFrequencyAnalysis analysis on f
-; NEWPM-NEXT:         BranchProbabilityAnalysis analysis on f
-; NEWPM-NEXT:     LoopLoadEliminationPass on f
-; NEWPM-NEXT:     InstCombinePass on f
-; NEWPM-NEXT:     SimplifyCFGPass on f
-; NEWPM-NEXT:     SLPVectorizerPass on f
-; NEWPM-NEXT:     VectorCombinePass on f
-; NEWPM-NEXT:     InstCombinePass on f
-; NEWPM-NEXT:     LoopUnrollPass on f
-; NEWPM-NEXT:     WarnMissedTransformationsPass on f
-; NEWPM-NEXT:     InstCombinePass on f
-; NEWPM-NEXT:     RequireAnalysisPass<{{.*}}> on f
-; NEWPM-NEXT:     FunctionToLoopPassAdaptor on f
-; NEWPM-NEXT:       PassManager<{{.*}}> on f
-; NEWPM-NEXT:         LoopSimplifyPass on f
-; NEWPM-NEXT:         LCSSAPass on f
-; NEWPM-NEXT:     AlignmentFromAssumptionsPass on f
-; NEWPM-NEXT:     LoopSinkPass on f
-; NEWPM-NEXT:     InstSimplifyPass on f
-; NEWPM-NEXT:     DivRemPairsPass on f
-; NEWPM-NEXT:     SimplifyCFGPass on f
-; NEWPM-NEXT:     SpeculateAroundPHIsPass on f
-; NEWPM-NEXT: CGProfilePass on [module]
-; NEWPM-NEXT: GlobalDCEPass on [module]
-; NEWPM-NEXT: ConstantMergePass on [module]
-; NEWPM-NEXT: RelLookupTableConverterPass on [module]
-; NEWPM-NEXT: ModuleToFunctionPassAdaptor on [module]
-; NEWPM-NEXT:   PassManager<{{.*}}> on f
-; NEWPM-NEXT:     AnnotationRemarksPass on f
-; NEWPM-NEXT: VerifierPass on [module]
-; NEWPM-NEXT:   VerifierAnalysis analysis on [module]
-; NEWPM-NEXT: BitcodeWriterPass on [module]
-
 define void @f() {
   ret void
 }

diff  --git a/llvm/test/Other/pass-pipeline-parsing.ll b/llvm/test/Other/pass-pipeline-parsing.ll
index 118103172a4a..668b06de862c 100644
--- a/llvm/test/Other/pass-pipeline-parsing.ll
+++ b/llvm/test/Other/pass-pipeline-parsing.ll
@@ -142,7 +142,7 @@
 ; RUN:     | FileCheck %s --check-prefix=CHECK-NESTED-FP-LP
 ; CHECK-NESTED-FP-LP: Running pass: NoOpLoopPass
 
-; RUN: opt -disable-output -debug-pass-manager -debug-pass-manager-verbose \
+; RUN: opt -disable-output -debug-pass-manager=verbose \
 ; RUN:     -passes='module(no-op-function,no-op-loop,no-op-cgscc,cgscc(no-op-function,no-op-loop),function(no-op-loop))' %s 2>&1 \
 ; RUN:     | FileCheck %s --check-prefix=CHECK-ADAPTORS
 ; CHECK-ADAPTORS: Running pass: ModuleToFunctionPassAdaptor
@@ -167,7 +167,7 @@
 ; RUN: opt -disable-output -debug-pass-manager \
 ; RUN:     -passes='module(function(no-op-function,loop(no-op-loop,no-op-loop)))' %s 2>&1 \
 ; RUN:     | FileCheck %s --check-prefix=CHECK-MANAGERS-NO-VERBOSE
-; RUN: opt -disable-output -debug-pass-manager -debug-pass-manager-verbose \
+; RUN: opt -disable-output -debug-pass-manager=verbose \
 ; RUN:     -passes='module(function(no-op-function,loop(no-op-loop,no-op-loop)))' %s 2>&1 \
 ; RUN:     | FileCheck %s --check-prefix=CHECK-MANAGERS
 ; CHECK-MANAGERS: Running pass: PassManager{{.*}}Function

diff  --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp
index 07712ce74bac..5ecee9ad372c 100644
--- a/llvm/tools/opt/NewPMDriver.cpp
+++ b/llvm/tools/opt/NewPMDriver.cpp
@@ -52,9 +52,17 @@ cl::opt<std::string>
                    cl::value_desc("filename"));
 } // namespace llvm
 
-static cl::opt<bool>
-    DebugPM("debug-pass-manager", cl::Hidden,
-            cl::desc("Print pass management debugging information"));
+enum class DebugLogging { None, Normal, Verbose };
+
+static cl::opt<DebugLogging> DebugPM(
+    "debug-pass-manager", cl::Hidden, cl::ValueOptional,
+    cl::desc("Print pass management debugging information"),
+    cl::init(DebugLogging::None),
+    cl::values(
+        clEnumValN(DebugLogging::Normal, "", ""),
+        clEnumValN(
+            DebugLogging::Verbose, "verbose",
+            "Print extra information about adaptors and pass managers")));
 
 static cl::list<std::string>
     PassPlugins("load-pass-plugin",
@@ -283,7 +291,10 @@ bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM,
   ModuleAnalysisManager MAM;
 
   PassInstrumentationCallbacks PIC;
-  StandardInstrumentations SI(DebugPM, VerifyEachPass);
+  PrintPassOptions PrintPassOpts;
+  PrintPassOpts.Verbose = DebugPM == DebugLogging::Verbose;
+  StandardInstrumentations SI(DebugPM != DebugLogging::None, VerifyEachPass,
+                              PrintPassOpts);
   SI.registerCallbacks(PIC, &FAM);
   DebugifyEachInstrumentation Debugify;
   if (DebugifyEach)


        


More information about the cfe-commits mailing list