diff options
author | Brian Gaeke <gaeke@uiuc.edu> | 2003-08-14 06:07:57 +0000 |
---|---|---|
committer | Brian Gaeke <gaeke@uiuc.edu> | 2003-08-14 06:07:57 +0000 |
commit | 1d3fa21cdd115b48241ff031f01e6b489b077abf (patch) | |
tree | 6b7b5d0c1eb585d8f8e911bf9a633c9f528c4fee | |
parent | e69f72758bbf652673edffd0f3bfdce77641e472 (diff) |
Add new method to FunctionPassManager to add ImmutablePasses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7838 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/PassManager.h | 6 | ||||
-rw-r--r-- | lib/VMCore/Pass.cpp | 1 | ||||
-rw-r--r-- | lib/VMCore/PassManagerT.h | 21 |
3 files changed, 27 insertions, 1 deletions
diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index 5a313d5a6f..c30164b540 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -34,6 +34,7 @@ public: }; class FunctionPass; +class ImmutablePass; class Function; class FunctionPassManager { @@ -50,6 +51,11 @@ public: /// void add(FunctionPass *P); + /// add - ImmutablePasses are not FunctionPasses, so we have a + /// special hack to get them into a FunctionPassManager. + /// + void add(ImmutablePass *IP); + /// run - Execute all of the passes scheduled for execution. Keep /// track of whether any of the passes modifies the function, and if /// so, return true. diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 711b6108a1..6fb3ef0c40 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -78,6 +78,7 @@ bool PassManager::run(Module &M) { return PM->run(M); } 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); } diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 5ccb76751b..9f47665b53 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -444,8 +444,27 @@ public: 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 |