Implement new -debug-pass=Arguments option that causes PassManager to
authorChris Lattner <sabre@nondot.org>
Tue, 30 Jul 2002 19:51:02 +0000 (19:51 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 30 Jul 2002 19:51:02 +0000 (19:51 +0000)
print out the command line options for the optimizations it is running.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3165 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Pass.cpp
lib/VMCore/PassManagerT.h

index d60a50053cf76197563b860effa009bd58a959bd..39766e357057bffd25f972962eb46209c7171f4d 100644 (file)
@@ -126,6 +126,19 @@ TimingInfo::~TimingInfo() {
 }
 
 
+void PMDebug::PrintArgumentInformation(const Pass *P) {
+  // Print out passes in pass manager...
+  if (const AnalysisResolver *PM = dynamic_cast<const AnalysisResolver*>(P)) {
+    for (unsigned i = 0, e = PM->getNumContainedPasses(); i != e; ++i)
+      PrintArgumentInformation(PM->getContainedPass(i));
+
+  } else {  // Normal pass.  Print argument information...
+    // Print out arguments for registered passes that are _optimizations_
+    if (const PassInfo *PI = P->getPassInfo())
+      if (PI->getPassType() & PassInfo::Optimization)
+        std::cerr << " -" << PI->getPassArgument();
+  }
+}
 
 void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
                                    Pass *P, Annotable *V) {
index 555bcaae1062ff60e41df5b3b1c278405d59bc6d..b4155e42a49b6061021e25e2629294fd47043c57 100644 (file)
@@ -29,7 +29,7 @@ class Annotable;
 
 // Different debug levels that can be enabled...
 enum PassDebugLevel {
-  None, Structure, Executions, Details
+  None, Arguments, Structure, Executions, Details
 };
 
 static cl::opt<enum PassDebugLevel>
@@ -37,7 +37,7 @@ PassDebugging("debug-pass", cl::Hidden,
               cl::desc("Print PassManager debugging information"),
               cl::values(
   clEnumVal(None      , "disable debug output"),
-  // TODO: add option to print out pass names "PassOptions"
+  clEnumVal(Arguments , "print pass arguments to pass to 'opt'"),
   clEnumVal(Structure , "print pass structure before run()"),
   clEnumVal(Executions, "print pass name before it is executed"),
   clEnumVal(Details   , "print pass details when it is executed"),
@@ -48,13 +48,20 @@ PassDebugging("debug-pass", cl::Hidden,
 // instantiated by the template.
 //
 struct PMDebug {
-  // If compiled in debug mode, these functions can be enabled by setting
-  // -debug-pass on the command line of the tool being used.
-  //
-  static void PrintPassStructure(Pass *P) {
-    if (PassDebugging >= Structure)
-      P->dumpPassStructure();
+  static void PerformPassStartupStuff(Pass *P) {
+    // If debugging is enabled, print out argument information...
+    if (PassDebugging >= Arguments) {
+      std::cerr << "Pass Arguments: ";
+      PrintArgumentInformation(P);
+      std::cerr << "\n";
+
+      // Print the pass execution structure
+      if (PassDebugging >= Structure)
+        P->dumpPassStructure();
+    }
   }
+
+  static void PrintArgumentInformation(const Pass *P);
   static void PrintPassInformation(unsigned,const char*,Pass *, Annotable *);
   static void PrintAnalysisSetInfo(unsigned,const char*,Pass *P,
                                    const std::vector<AnalysisID> &);
@@ -151,7 +158,7 @@ public:
 
 
     // Output debug information...
-    if (Parent == 0) PMDebug::PrintPassStructure(this);
+    if (Parent == 0) PMDebug::PerformPassStartupStuff(this);
 
     // Run all of the passes
     for (unsigned i = 0, e = Passes.size(); i < e; ++i) {
@@ -306,6 +313,12 @@ public:
     return 1 + Parent->getDepth();
   }
 
+  virtual unsigned getNumContainedPasses() const { return Passes.size(); }
+  virtual const Pass *getContainedPass(unsigned N) const {
+    assert(N < Passes.size() && "Pass number out of range!");
+    return Passes[N];
+  }
+
   // add - Add a pass to the queue of passes to run.  This passes ownership of
   // the Pass to the PassManager.  When the PassManager is destroyed, the pass
   // will be destroyed as well, so there is no need to delete the pass.  This