Add doInitialization and doFinalization support in FunctionManager_New.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31745 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2006-11-15 01:27:05 +00:00
parent abb81054d1
commit 3799f97d53

View File

@ -14,6 +14,7 @@
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/ModuleProvider.h"
#include <vector> #include <vector>
#include <map> #include <map>
@ -174,6 +175,13 @@ public:
/// Return true IFF AnalysisID AID is currently available. /// Return true IFF AnalysisID AID is currently available.
Pass *getAnalysisPassFromManager(AnalysisID AID); Pass *getAnalysisPassFromManager(AnalysisID AID);
/// doInitialization - Run all of the initializers for the function passes.
///
bool doInitialization(Module &M);
/// doFinalization - Run all of the initializers for the function passes.
///
bool doFinalization(Module &M);
private: private:
// Active Pass Managers // Active Pass Managers
BasicBlockPassManager_New *activeBBPassManager; BasicBlockPassManager_New *activeBBPassManager;
@ -355,8 +363,8 @@ void CommonPassManagerImpl::addPassToManager (Pass *P,
// implementations it needs. // implementations it needs.
// //
void CommonPassManagerImpl::initializeAnalysisImpl(Pass *P) { void CommonPassManagerImpl::initializeAnalysisImpl(Pass *P) {
AnalysisUsage AnUsage; AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage); P->getAnalysisUsage(AnUsage);
for (std::vector<const PassInfo *>::const_iterator for (std::vector<const PassInfo *>::const_iterator
I = AnUsage.getRequiredSet().begin(), I = AnUsage.getRequiredSet().begin(),
@ -441,6 +449,18 @@ FunctionPassManager_New::runOnModule(Module &M) {
return FPM->runOnModule(M); return FPM->runOnModule(M);
} }
/// doInitialization - Run all of the initializers for the function passes.
///
bool FunctionPassManager_New::doInitialization() {
return FPM->doInitialization(*MP->getModule());
}
/// doFinalization - Run all of the initializers for the function passes.
///
bool FunctionPassManager_New::doFinalization() {
return FPM->doFinalization(*MP->getModule());
}
// FunctionPassManagerImpl_New implementation // FunctionPassManagerImpl_New implementation
// FunctionPassManager // FunctionPassManager
@ -517,6 +537,36 @@ Pass *FunctionPassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) {
return NULL; return NULL;
} }
inline bool FunctionPassManagerImpl_New::doInitialization(Module &M) {
bool Changed = false;
for (std::vector<Pass *>::iterator itr = passVectorBegin(),
e = passVectorEnd(); itr != e; ++itr) {
Pass *P = *itr;
FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
Changed |= FP->doInitialization(M);
}
return Changed;
}
inline bool FunctionPassManagerImpl_New::doFinalization(Module &M) {
bool Changed = false;
for (std::vector<Pass *>::iterator itr = passVectorBegin(),
e = passVectorEnd(); itr != e; ++itr) {
Pass *P = *itr;
FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
Changed |= FP->doFinalization(M);
}
return Changed;
}
// ModulePassManager implementation // ModulePassManager implementation
/// Add P into pass vector if it is manageble. If P is a FunctionPass /// Add P into pass vector if it is manageble. If P is a FunctionPass