We need to propagate the debug location information even when dealing with the
[oota-llvm.git] / lib / VMCore / PassManager.cpp
index e3d1c5364e95f5e8869e952a845a7c7528a8e7f0..4335757a5093ca7f81c83fae037ba51b064161d2 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Analysis/Dominators.h"
 #include "llvm-c/Core.h"
 #include <algorithm>
+#include <cstdio>
 #include <vector>
 #include <map>
 using namespace llvm;
@@ -457,8 +458,10 @@ void PMTopLevelManager::schedulePass(Pass *P) {
   // generate the analysis again. Stale analysis info should not be
   // available at this point.
   if (P->getPassInfo() &&
-      P->getPassInfo()->isAnalysis() && findAnalysisPass(P->getPassInfo()))
+      P->getPassInfo()->isAnalysis() && findAnalysisPass(P->getPassInfo())) {
+    delete P;
     return;
+  }
 
   AnalysisUsage *AnUsage = findAnalysisUsage(P);
 
@@ -676,7 +679,7 @@ void PMDataManager::verifyDomInfo(Pass &P, Function &F) {
   if (!VerifyDomInfo || !P.getResolver())
     return;
 
-  DominatorTree *DT = P.getAnalysisToUpdate<DominatorTree>();
+  DominatorTree *DT = P.getAnalysisIfAvailable<DominatorTree>();
   if (!DT)
     return;
 
@@ -692,7 +695,7 @@ void PMDataManager::verifyDomInfo(Pass &P, Function &F) {
     assert (0 && "Invalid dominator info");
   }
 
-  DominanceFrontier *DF = P.getAnalysisToUpdate<DominanceFrontier>();
+  DominanceFrontier *DF = P.getAnalysisIfAvailable<DominanceFrontier>();
   if (!DF) 
     return;
 
@@ -724,12 +727,12 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
         && std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == 
         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";
       }
+      AvailableAnalysis.erase(Info);
     }
   }
 
@@ -1085,8 +1088,8 @@ PMDataManager::~PMDataManager() {
 
 //===----------------------------------------------------------------------===//
 // NOTE: Is this the right place to define this method ?
-// getAnalysisToUpdate - Return an analysis result or null if it doesn't exist
-Pass *AnalysisResolver::getAnalysisToUpdate(AnalysisID ID, bool dir) const {
+// getAnalysisIfAvailable - Return analysis result or null if it doesn't exist.
+Pass *AnalysisResolver::getAnalysisIfAvailable(AnalysisID ID, bool dir) const {
   return PM.findAnalysisPass(ID, dir);
 }
 
@@ -1137,7 +1140,7 @@ BBPassManager::runOnFunction(Function &F) {
 }
 
 // Implement doInitialization and doFinalization
-inline bool BBPassManager::doInitialization(Module &M) {
+bool BBPassManager::doInitialization(Module &M) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
@@ -1148,7 +1151,7 @@ inline bool BBPassManager::doInitialization(Module &M) {
   return Changed;
 }
 
-inline bool BBPassManager::doFinalization(Module &M) {
+bool BBPassManager::doFinalization(Module &M) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
@@ -1159,7 +1162,7 @@ inline bool BBPassManager::doFinalization(Module &M) {
   return Changed;
 }
 
-inline bool BBPassManager::doInitialization(Function &F) {
+bool BBPassManager::doInitialization(Function &F) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
@@ -1170,7 +1173,7 @@ inline bool BBPassManager::doInitialization(Function &F) {
   return Changed;
 }
 
-inline bool BBPassManager::doFinalization(Function &F) {
+bool BBPassManager::doFinalization(Function &F) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
@@ -1239,7 +1242,7 @@ bool FunctionPassManager::doFinalization() {
 //===----------------------------------------------------------------------===//
 // FunctionPassManagerImpl implementation
 //
-inline bool FunctionPassManagerImpl::doInitialization(Module &M) {
+bool FunctionPassManagerImpl::doInitialization(Module &M) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {  
@@ -1250,7 +1253,7 @@ inline bool FunctionPassManagerImpl::doInitialization(Module &M) {
   return Changed;
 }
 
-inline bool FunctionPassManagerImpl::doFinalization(Module &M) {
+bool FunctionPassManagerImpl::doFinalization(Module &M) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {  
@@ -1345,7 +1348,7 @@ bool FPPassManager::runOnModule(Module &M) {
   return Changed |= doFinalization(M);
 }
 
-inline bool FPPassManager::doInitialization(Module &M) {
+bool FPPassManager::doInitialization(Module &M) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {  
@@ -1356,7 +1359,7 @@ inline bool FPPassManager::doInitialization(Module &M) {
   return Changed;
 }
 
-inline bool FPPassManager::doFinalization(Module &M) {
+bool FPPassManager::doFinalization(Module &M) {
   bool Changed = false;
 
   for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {