[llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp

Devang Patel dpatel at apple.com
Fri Nov 10 16:42:33 PST 2006



Changes in directory llvm/lib/VMCore:

PassManager.cpp updated: 1.11 -> 1.12
---
Log message:

Keep track of analysis required by the passes. Force use of new pass 
manager if a pass does not preserve analysis that is used by other 
passes.


---
Diffs of the changes:  (+18 -5)

 PassManager.cpp |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)


Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.11 llvm/lib/VMCore/PassManager.cpp:1.12
--- llvm/lib/VMCore/PassManager.cpp:1.11	Fri Nov 10 15:33:13 2006
+++ llvm/lib/VMCore/PassManager.cpp	Fri Nov 10 18:42:16 2006
@@ -142,9 +142,18 @@
   AnalysisUsage AnUsage;
   P->getAnalysisUsage(AnUsage);
 
-  // If this pass is not preserving information that is required by the other passes
-  // managed by this manager then use new manager
-  // TODO
+  // If this pass is not preserving information that is required by the other
+  // passes managed by this manager then use new manager
+  if (!AnUsage.getPreservesAll()) {
+    const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
+    for (std::vector<AnalysisID>::iterator I = RequiredAnalysis.begin(),
+           E = RequiredAnalysis.end(); I != E; ++I) {
+      if (std::find(PreservedSet.begin(), PreservedSet.end(), *I) == 
+          PreservedSet.end())
+        // This analysis is not preserved. Need new manager.
+        return false;
+    }
+  }
   return true;
 }
 
@@ -157,8 +166,12 @@
 
 /// Augment RequiredSet by adding analysis required by pass P.
 void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) {
+  AnalysisUsage AnUsage;
+  P->getAnalysisUsage(AnUsage);
+  const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
 
-  // TODO
+  // FIXME: What about duplicates ?
+  RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(), RequiredSet.end());
 }
 
 /// Remove AnalysisID from the RequiredSet
@@ -375,7 +388,7 @@
 bool
 PassManagerImpl_New::addPass(Pass *P) {
 
-  if (!activeManager) {
+  if (!activeManager || !activeManager->addPass(P)) {
     activeManager = new ModulePassManager_New();
     PassManagers.push_back(activeManager);
   }






More information about the llvm-commits mailing list