Print debug message only if there are dead passes.
[oota-llvm.git] / lib / VMCore / PassManager.cpp
index 7db6aa2643d804ac13660fd89f380533451e875c..e1f8afe3b0ea069f77589a5e26e8ac05ab080731 100644 (file)
@@ -360,10 +360,10 @@ public:
   }
 };
 
-static TimingInfo *TheTimeInfo;
-
 } // End of anon namespace
 
+static TimingInfo *TheTimeInfo;
+
 //===----------------------------------------------------------------------===//
 // PMTopLevelManager implementation
 
@@ -429,7 +429,8 @@ void PMTopLevelManager::schedulePass(Pass *P) {
   // If P is an analysis pass and it is available then do not
   // generate the analysis again. Stale analysis info should not be
   // available at this point.
-  if (P->isAnalysis() && findAnalysisPass(P->getPassInfo()))
+  if (P->getPassInfo() &&
+      P->getPassInfo()->isAnalysis() && findAnalysisPass(P->getPassInfo()))
     return;
 
   AnalysisUsage AnUsage;
@@ -620,9 +621,15 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
     std::map<AnalysisID, Pass*>::iterator Info = I++;
     if (!dynamic_cast<ImmutablePass*>(Info->second)
         && std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == 
-           PreservedSet.end())
+        PreservedSet.end()) {
       // Remove this analysis
       AvailableAnalysis.erase(Info);
+      if (PassDebugging >= Details) {
+        Pass *S = Info->second;
+        cerr << " -- " <<  P->getPassName() << " is not preserving ";
+        cerr << S->getPassName() << "\n";
+      }
+    }
   }
 
   // Check inherited analysis also. If P is not preserving analysis
@@ -658,6 +665,12 @@ void PMDataManager::removeDeadPasses(Pass *P, const char *Msg,
 
   TPM->collectLastUses(DeadPasses, P);
 
+  if (PassDebugging >= Details && !DeadPasses.empty()) {
+    cerr << " -*- " <<  P->getPassName();
+    cerr << " is the last user of following pass instances.";
+    cerr << " Free these instances\n";
+  }
+
   for (SmallVector<Pass *, 12>::iterator I = DeadPasses.begin(),
          E = DeadPasses.end(); I != E; ++I) {
 
@@ -923,7 +936,11 @@ void PMDataManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {
   // When Pass manager is not able to order required analysis info, Pass manager
   // checks whether any lower level manager will be able to provide this 
   // analysis info on demand or not.
-  assert (0 && "Unable to handle Pass that requires lower level Analysis pass");
+#ifndef NDEBUG
+  cerr << "Unable to schedule " << RequiredPass->getPassName();
+  cerr << " required by " << P->getPassName() << "\n";
+#endif
+  assert (0 && "Unable to schedule pass");
 }
 
 // Destructor
@@ -1158,6 +1175,9 @@ bool FPPassManager::runOnFunction(Function &F) {
 
   if (F.isDeclaration())
     return false;
+  
+  // Collect inherited analysis from Module level pass manager.
+  populateInheritedAnalysis(TPM->activeStack);
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
     FunctionPass *FP = getContainedPass(Index);
@@ -1470,6 +1490,7 @@ void FunctionPass::assignPassManager(PMStack &PMS,
 
     // [1] Create new Function Pass Manager
     FPP = new FPPassManager(PMD->getDepth() + 1);
+    FPP->populateInheritedAnalysis(PMS);
 
     // [2] Set up new manager's top level manager
     PMTopLevelManager *TPM = PMD->getTopLevelManager();