[llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp PassManagerT.h

Brian Gaeke gaeke at niobe.cs.uiuc.edu
Thu Aug 14 01:09:01 PDT 2003


Changes in directory llvm/lib/VMCore:

Pass.cpp updated: 1.45 -> 1.46
PassManagerT.h updated: 1.40 -> 1.41

---
Log message:

Add new method to FunctionPassManager to add ImmutablePasses.


---
Diffs of the changes:

Index: llvm/lib/VMCore/Pass.cpp
diff -u llvm/lib/VMCore/Pass.cpp:1.45 llvm/lib/VMCore/Pass.cpp:1.46
--- llvm/lib/VMCore/Pass.cpp:1.45	Thu Aug 14 00:20:28 2003
+++ llvm/lib/VMCore/Pass.cpp	Thu Aug 14 01:07:55 2003
@@ -78,6 +78,7 @@
 FunctionPassManager::FunctionPassManager() : PM(new PassManagerT<Function>()) {}
 FunctionPassManager::~FunctionPassManager() { delete PM; }
 void FunctionPassManager::add(FunctionPass *P) { PM->add(P); }
+void FunctionPassManager::add(ImmutablePass *IP) { PM->add(IP); }
 bool FunctionPassManager::run(Function &F) { return PM->run(F); }
 
 


Index: llvm/lib/VMCore/PassManagerT.h
diff -u llvm/lib/VMCore/PassManagerT.h:1.40 llvm/lib/VMCore/PassManagerT.h:1.41
--- llvm/lib/VMCore/PassManagerT.h:1.40	Thu Aug 14 00:20:28 2003
+++ llvm/lib/VMCore/PassManagerT.h	Thu Aug 14 01:07:55 2003
@@ -444,8 +444,27 @@
     P->addToPassManager(this, AnUsage);
   }
 
-private:
+  // add - H4x0r an ImmutablePass into a PassManager that might not be
+  // expecting one.
+  //
+  void add(ImmutablePass *P) {
+    // Get information about what analyses the pass uses...
+    AnalysisUsage AnUsage;
+    P->getAnalysisUsage(AnUsage);
+    const std::vector<AnalysisID> &Required = AnUsage.getRequiredSet();
+
+    // Loop over all of the analyses used by this pass,
+    for (std::vector<AnalysisID>::const_iterator I = Required.begin(),
+           E = Required.end(); I != E; ++I) {
+      if (getAnalysisOrNullDown(*I) == 0)
+        add((PassClass*)(*I)->createPass());
+    }
 
+    // Add the ImmutablePass to this PassManager.
+    addPass(P, AnUsage);
+  }
+
+private:
   // addPass - These functions are used to implement the subclass specific
   // behaviors present in PassManager.  Basically the add(Pass*) method ends up
   // reflecting its behavior into a Pass::addToPassManager call.  Subclasses of





More information about the llvm-commits mailing list