Add testcase for prev. commit. Minor fixes
[oota-llvm.git] / lib / VMCore / PassManager.cpp
index e7d7c5bc7288d171602b34d0ee7925ec400811fe..312379479d6a65dcda5c7adc1c47b703e4bf5a24 100644 (file)
@@ -426,6 +426,13 @@ void PMTopLevelManager::schedulePass(Pass *P) {
   // Give pass a chance to prepare the stage.
   P->preparePassManager(activeStack);
 
+  // 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->getPassInfo() &&
+      P->getPassInfo()->isAnalysis() && findAnalysisPass(P->getPassInfo()))
+    return;
+
   AnalysisUsage AnUsage;
   P->getAnalysisUsage(AnUsage);
   const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
@@ -1152,6 +1159,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);
@@ -1464,6 +1474,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();