Move enum PassDebugLevel from PassManagerT.h to Pass.h.
authorDevang Patel <dpatel@apple.com>
Wed, 13 Dec 2006 20:03:48 +0000 (20:03 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 13 Dec 2006 20:03:48 +0000 (20:03 +0000)
Use PDL as the prefix for these enums.
Define and use PassDebugging_New in new PassManager.

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

include/llvm/Pass.h
lib/VMCore/Pass.cpp
lib/VMCore/PassManager.cpp
lib/VMCore/PassManagerT.h

index 15381ac978b13a245bdf4898cf770ca98e12340a..b376b8b1d39037e4fa2e15571c0e3f38e6fc10a5 100644 (file)
@@ -355,6 +355,11 @@ private:
 /// @brief This is the storage for the -time-passes option.
 extern bool TimePassesIsEnabled;
 
+// Different debug levels that can be enabled...
+enum PassDebugLevel {
+  PDLNone, PDLArguments, PDLStructure, PDLExecutions, PDLDetails
+};
+
 } // End llvm namespace
 
 // Include support files that contain important APIs commonly used by Passes,
index 8c5a2f760ebbf2b9bd9e3087df51c279c39343cc..650a7e6191a419180c02abd8d6d14fc6bfa1b205 100644 (file)
@@ -122,7 +122,7 @@ void PMDebug::PrintArgumentInformation(const Pass *P) {
 
 void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
                                    Pass *P, Module *M) {
-  if (PassDebugging >= Executions) {
+  if (PassDebugging >= PDLExecutions) {
     cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '"
          << P->getPassName();
     if (M) cerr << "' on Module '" << M->getModuleIdentifier() << "'\n";
@@ -132,7 +132,7 @@ void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
 
 void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
                                    Pass *P, Function *F) {
-  if (PassDebugging >= Executions) {
+  if (PassDebugging >= PDLExecutions) {
     cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '"
          << P->getPassName();
     if (F) cerr << "' on Function '" << F->getName();
@@ -142,7 +142,7 @@ void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
 
 void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
                                    Pass *P, BasicBlock *BB) {
-  if (PassDebugging >= Executions) {
+  if (PassDebugging >= PDLExecutions) {
     cerr << (void*)P << std::string(Depth*2+1, ' ') << Action << " '"
          << P->getPassName();
     if (BB) cerr << "' on BasicBlock '" << BB->getName();
@@ -152,7 +152,7 @@ void PMDebug::PrintPassInformation(unsigned Depth, const char *Action,
 
 void PMDebug::PrintAnalysisSetInfo(unsigned Depth, const char *Msg,
                                    Pass *P, const std::vector<AnalysisID> &Set){
-  if (PassDebugging >= Details && !Set.empty()) {
+  if (PassDebugging >= PDLDetails && !Set.empty()) {
     cerr << (void*)P << std::string(Depth*2+3, ' ') << Msg << " Analyses:";
     for (unsigned i = 0; i != Set.size(); ++i) {
       if (i) cerr << ",";
index d67d25a3f4cb039565740e07bdb20df2c44f25f2..056a2a87c2465efb2a4ff94838749be7e0839622 100644 (file)
@@ -13,6 +13,7 @@
 
 
 #include "llvm/PassManager.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Module.h"
 #include "llvm/ModuleProvider.h"
 #include "llvm/Support/Streams.h"
@@ -84,6 +85,27 @@ using namespace llvm;
 // ModulePassManagers.
 //===----------------------------------------------------------------------===//
 
+namespace llvm {
+
+//===----------------------------------------------------------------------===//
+// Pass debugging information.  Often it is useful to find out what pass is
+// running when a crash occurs in a utility.  When this library is compiled with
+// debugging on, a command line option (--debug-pass) is enabled that causes the
+// pass name to be printed before it executes.
+//
+
+static cl::opt<enum PassDebugLevel>
+PassDebugging_New("debug-pass", cl::Hidden,
+                  cl::desc("Print PassManager debugging information"),
+                  cl::values(
+  clEnumVal(PDLNone      , "disable debug output"),
+  clEnumVal(PDLArguments , "print pass arguments to pass to 'opt'"),
+  clEnumVal(PDLStructure , "print pass structure before run()"),
+  clEnumVal(PDLExecutions, "print pass name before it is executed"),
+  clEnumVal(PDLDetails   , "print pass details when it is executed"),
+                             clEnumValEnd));
+} // End of llvm namespace
+
 #ifndef USE_OLD_PASSMANAGER
 namespace llvm {
 
@@ -1241,6 +1263,10 @@ bool PassManagerImpl_New::addPass(Pass *P) {
 bool PassManagerImpl_New::run(Module &M) {
 
   bool Changed = false;
+
+  if (PassDebugging_New >= PDLStructure)
+    dumpPasses();
+
   for (std::vector<Pass *>::iterator I = passManagersBegin(),
          E = passManagersEnd(); I != E; ++I) {
     ModulePassManager *MP = dynamic_cast<ModulePassManager *>(*I);
index 62a340beb866adaa96f4d85471066b2a65ef46f4..bb04cc1ba5b3d7582a88bc1fd40bb28cb235e27f 100644 (file)
@@ -37,21 +37,16 @@ namespace llvm {
 // pass name to be printed before it executes.
 //
 
-// Different debug levels that can be enabled...
-enum PassDebugLevel {
-  None, Arguments, Structure, Executions, Details
-};
-
 static cl::opt<enum PassDebugLevel>
 PassDebugging("debug-pass", cl::Hidden,
-              cl::desc("Print PassManager debugging information"),
-              cl::values(
-  clEnumVal(None      , "disable debug output"),
-  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"),
-                         clEnumValEnd));
+             cl::desc("Print PassManager debugging information"),
+             cl::values(
+  clEnumVal(PDLNone      , "disable debug output"),
+  clEnumVal(PDLArguments , "print pass arguments to pass to 'opt'"),
+  clEnumVal(PDLStructure , "print pass structure before run()"),
+  clEnumVal(PDLExecutions, "print pass name before it is executed"),
+  clEnumVal(PDLDetails   , "print pass details when it is executed"),
+                        clEnumValEnd));
 
 //===----------------------------------------------------------------------===//
 // PMDebug class - a set of debugging functions, that are not to be
@@ -60,13 +55,13 @@ PassDebugging("debug-pass", cl::Hidden,
 struct PMDebug {
   static void PerformPassStartupStuff(Pass *P) {
     // If debugging is enabled, print out argument information...
-    if (PassDebugging >= Arguments) {
+    if (PassDebugging >= PDLArguments) {
       cerr << "Pass Arguments: ";
       PrintArgumentInformation(P);
       cerr << "\n";
 
       // Print the pass execution structure
-      if (PassDebugging >= Structure)
+      if (PassDebugging >= PDLStructure)
         P->dumpPassStructure();
     }
   }
@@ -546,7 +541,7 @@ public:
         cerr << "Analysis '" << (*I)->getPassName()
              << "' used but not available!";
         assert(0 && "Analysis used but not available!");
-      } else if (PassDebugging == Details) {
+      } else if (PassDebugging == PDLDetails) {
         if ((*I)->getPassName() != std::string(Impl->getPassName()))
           cerr << "    Interface '" << (*I)->getPassName()
                << "' implemented by '" << Impl->getPassName() << "'\n";
@@ -635,7 +630,7 @@ private:
         cerr << "Analysis '" << (*I)->getPassName()
              << "' used but not available!";
         assert(0 && "Analysis used but not available!");
-      } else if (PassDebugging == Details) {
+      } else if (PassDebugging == PDLDetails) {
         if ((*I)->getPassName() != std::string(Impl->getPassName()))
           cerr << "    Interface '" << (*I)->getPassName()
                << "' implemented by '" << Impl->getPassName() << "'\n";