Adding some debug information to PassManager
authorVictor Oliveira <Victor.Oliveira@amd.com>
Wed, 18 Jul 2012 19:59:29 +0000 (19:59 +0000)
committerVictor Oliveira <Victor.Oliveira@amd.com>
Wed, 18 Jul 2012 19:59:29 +0000 (19:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160446 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/PassManager.cpp

index d4638c57827f60233844e09836c660eec0ed5dd3..4530c0495f1affb7a9df713055efcab27474421e 100644 (file)
@@ -593,6 +593,26 @@ void PMTopLevelManager::schedulePass(Pass *P) {
       Pass *AnalysisPass = findAnalysisPass(*I);
       if (!AnalysisPass) {
         const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(*I);
+
+        if (PI == NULL) {
+          // Pass P is not in the global PassRegistry
+          dbgs() << "Pass '"  << P->getPassName() << "' is not initialized." << "\n";
+          dbgs() << "Verify if there is a pass dependency cycle." << "\n";
+          dbgs() << "Required Passes:" << "\n";
+          for (AnalysisUsage::VectorType::const_iterator I2 = RequiredSet.begin(),
+                 E = RequiredSet.end(); I2 != E && I2 != I; ++I2) {
+            Pass *AnalysisPass2 = findAnalysisPass(*I2);
+            if (AnalysisPass2) {
+              dbgs() << "\t" << AnalysisPass2->getPassName() << "\n";
+            }
+            else {
+              dbgs() << "\t"   << "Error: Required pass not found! Possible causes:"  << "\n";
+              dbgs() << "\t\t" << "- Pass misconfiguration (e.g.: missing macros)"    << "\n";
+              dbgs() << "\t\t" << "- Corruption of the global PassRegistry"           << "\n";
+            }
+          }
+        }
+
         assert(PI && "Expected required passes to be initialized");
         AnalysisPass = PI->createPass();
         if (P->getPotentialPassManagerType () ==