Keep track of inherited analysis. For example, if a loop pass does not
authorDevang Patel <dpatel@apple.com>
Tue, 6 Mar 2007 01:55:46 +0000 (01:55 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 6 Mar 2007 01:55:46 +0000 (01:55 +0000)
preserve dominator info then it should update parent FPPassManager's
available analysis info to reflect this.

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

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

index 601420eb37ecbdcbded310e3859754e497cc3baf..d517c41f17f92ed63af86de8f86977d6cb01dda2 100644 (file)
@@ -64,7 +64,8 @@ enum PassManagerType {
   PMT_CallGraphPassManager,  /// CGPassManager
   PMT_FunctionPassManager,   /// FPPassManager
   PMT_LoopPassManager,       /// LPPassManager
-  PMT_BasicBlockPassManager  /// BBPassManager
+  PMT_BasicBlockPassManager, /// BBPassManager
+  PMT_Last
 };
 
 typedef enum PassManagerType PassManagerType;
index b2a0a9fa8c46a63d43f8f6f52f0b0b9bc8ae9790..0bc2def316379e7968a462e707700cbd94849004 100644 (file)
@@ -197,6 +197,7 @@ private:
 /// used by pass managers.
 class PMDataManager {
 public:
+
   PMDataManager(int Depth) : TPM(NULL), Depth(Depth) {
     initializeAnalysisInfo();
   }
@@ -223,6 +224,8 @@ public:
   /// Initialize available analysis information.
   void initializeAnalysisInfo() { 
     AvailableAnalysis.clear();
+    for (unsigned i = 0; i < PMT_Last; ++i)
+      InheritedAnalysis[i] = NULL;
   }
 
   /// Populate RequiredPasses with the analysis pass that are required by
@@ -262,6 +265,19 @@ public:
     assert ( 0 && "Invalid use of getPassManagerType");
     return PMT_Unknown; 
   }
+
+  std::map<AnalysisID, Pass*> *getAvailableAnalysis() {
+    return &AvailableAnalysis;
+  }
+
+  // Collect AvailableAnalysis from all the active Pass Managers.
+  void populateInheritedAnalysis(PMStack &PMS) {
+    unsigned Index = 0;
+    for (PMStack::iterator I = PMS.begin(), E = PMS.end();
+         I != E; ++I)
+      InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis();
+  }
+
 protected:
 
   // Top level manager.
@@ -270,6 +286,11 @@ protected:
   // Collection of pass that are managed by this manager
   std::vector<Pass *> PassVector;
 
+  // Collection of Analysis provided by Parent pass manager and
+  // used by current pass manager. At at time there can not be more
+  // then PMT_Last active pass mangers.
+  std::map<AnalysisID, Pass *> *InheritedAnalysis[PMT_Last];
+
 private:
   // Set of available Analysis. This information is used while scheduling 
   // pass. If a pass requires an analysis which is not not available then 
index 253530824338b594a7a2dce819f1b7c2f46bd053..72804be10072c8338c832b88b66fdbb0d3fcd2eb 100644 (file)
@@ -551,6 +551,27 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
         AvailableAnalysis.erase(Info);
     }
   }
+
+  // Check inherited analysis also. If P is not preserving analysis
+  // provided by parent manager then remove it here.
+  for (unsigned Index = 0; Index < PMT_Last; ++Index) {
+
+    if (!InheritedAnalysis[Index])
+      continue;
+
+    for (std::map<AnalysisID, Pass*>::iterator 
+           I = InheritedAnalysis[Index]->begin(),
+           E = InheritedAnalysis[Index]->end(); I != E; ) {
+      std::map<AnalysisID, Pass *>::iterator Info = I++;
+      if (std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == 
+          PreservedSet.end()) {
+        // Remove this analysis
+        if (!dynamic_cast<ImmutablePass*>(Info->second))
+          InheritedAnalysis[Index]->erase(Info);
+      }
+    }
+  }
+
 }
 
 /// Remove analysis passes that are not used any longer