From be1ffc6b8d3db7b1a9d512a1d53afd075d8e58c9 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 17 Jan 2007 20:30:17 +0000 Subject: [PATCH] Update assignPassManager() signature to allow selection of preferred pass manager type. This allows new FPPassManager to select Call Graph Pass Manager (if available) as its parent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33306 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Pass.h | 38 ++++++++++++++++++++++---------------- lib/VMCore/PassManager.cpp | 17 +++++++++++++---- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 9951a988bf0..7708d498f63 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -57,6 +57,20 @@ class PMDataManager; // AnalysisID - Use the PassInfo to identify a pass... typedef const PassInfo* AnalysisID; +/// Different types of internal pass managers. External pass managers +/// (PassManager and FunctionPassManager) are not represented here. +/// Ordering of pass manager types is important here. +enum PassManagerType { + PMT_Unknown = 0, + PMT_ModulePassManager = 1, /// MPPassManager + PMT_CallGraphPassManager, /// CGPassManager + PMT_FunctionPassManager, /// FPPassManager + PMT_LoopPassManager, /// LPPassManager + PMT_BasicBlockPassManager /// BBPassManager +}; + +typedef enum PassManagerType PassManagerType; + //===----------------------------------------------------------------------===// /// Pass interface - Implemented by all 'passes'. Subclass this if you are an /// interprocedural optimization or you do not fit into any of the more @@ -107,7 +121,8 @@ public: void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); } void dump() const; // dump - call print(std::cerr, 0); - virtual void assignPassManager(PMStack &PMS) {} + virtual void assignPassManager(PMStack &PMS, + PassManagerType T = PMT_Unknown) {} // Access AnalysisResolver inline void setResolver(AnalysisResolver *AR) { Resolver = AR; } inline AnalysisResolver *getResolver() { return Resolver; } @@ -200,7 +215,8 @@ public: virtual bool runPass(Module &M) { return runOnModule(M); } virtual bool runPass(BasicBlock&) { return false; } - virtual void assignPassManager(PMStack &PMS); + virtual void assignPassManager(PMStack &PMS, + PassManagerType T = PMT_ModulePassManager); // Force out-of-line virtual method. virtual ~ModulePass(); }; @@ -266,7 +282,8 @@ public: /// bool run(Function &F); - virtual void assignPassManager(PMStack &PMS); + virtual void assignPassManager(PMStack &PMS, + PassManagerType T = PMT_FunctionPassManager); }; @@ -320,19 +337,8 @@ public: virtual bool runPass(Module &M) { return false; } virtual bool runPass(BasicBlock &BB); - virtual void assignPassManager(PMStack &PMS); -}; - -/// Different types of internal pass managers. External pass managers -/// (PassManager and FunctionPassManager) are not represented here. -/// Ordering of pass manager types is important here. -enum PassManagerType { - PMT_Unknown = 0, - PMT_ModulePassManager = 1, /// MPPassManager - PMT_CallGraphPassManager, /// CGPassManager - PMT_FunctionPassManager, /// FPPassManager - PMT_LoopPassManager, /// LPPassManager - PMT_BasicBlockPassManager /// BBPassManager + virtual void assignPassManager(PMStack &PMS, + PassManagerType T = PMT_BasicBlockPassManager); }; /// PMStack diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 6f0c4527be3..476dad7215d 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -1202,7 +1202,8 @@ void PMStack::handleLastUserOverflow() { /// Find appropriate Module Pass Manager in the PM Stack and /// add self into that manager. -void ModulePass::assignPassManager(PMStack &PMS) { +void ModulePass::assignPassManager(PMStack &PMS, + PassManagerType PreferredType) { // Find Module Pass Manager while(!PMS.empty()) { @@ -1219,7 +1220,8 @@ void ModulePass::assignPassManager(PMStack &PMS) { /// Find appropriate Function Pass Manager or Call Graph Pass Manager /// in the PM Stack and add self into that manager. -void FunctionPass::assignPassManager(PMStack &PMS) { +void FunctionPass::assignPassManager(PMStack &PMS, + PassManagerType PreferredType) { // Find Module Pass Manager (TODO : Or Call Graph Pass Manager) while(!PMS.empty()) { @@ -1245,7 +1247,13 @@ void FunctionPass::assignPassManager(PMStack &PMS) { // [3] Assign manager to manage this new manager. This may create // and push new managers into PMS Pass *P = dynamic_cast(FPP); - P->assignPassManager(PMS); + + // If Call Graph Pass Manager is active then use it to manage + // this new Function Pass manager. + if (PMD->getPassManagerType() == PMT_CallGraphPassManager) + P->assignPassManager(PMS, PMT_CallGraphPassManager); + else + P->assignPassManager(PMS); // [4] Push new manager into PMS PMS.push(FPP); @@ -1257,7 +1265,8 @@ void FunctionPass::assignPassManager(PMStack &PMS) { /// Find appropriate Basic Pass Manager or Call Graph Pass Manager /// in the PM Stack and add self into that manager. -void BasicBlockPass::assignPassManager(PMStack &PMS) { +void BasicBlockPass::assignPassManager(PMStack &PMS, + PassManagerType PreferredType) { BBPassManager *BBP = NULL;