diff options
author | Devang Patel <dpatel@apple.com> | 2006-12-07 23:55:10 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-12-07 23:55:10 +0000 |
commit | e16634065021e36ae31f074f623a636924d6b8d1 (patch) | |
tree | 8cc565d851823c9d3e4fd780347c93879d8f2212 | |
parent | eb63b0a9d5089dd3119ba9c3cad9cf9ad79df0f7 (diff) | |
download | external_llvm-e16634065021e36ae31f074f623a636924d6b8d1.zip external_llvm-e16634065021e36ae31f074f623a636924d6b8d1.tar.gz external_llvm-e16634065021e36ae31f074f623a636924d6b8d1.tar.bz2 |
set Last User.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32342 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/PassManager.cpp | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index eb85465..375f0ff 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -243,6 +243,7 @@ public: /// Initialize available analysis information. void initializeAnalysisInfo() { + ForcedLastUses.clear(); AvailableAnalysis.clear(); // Include immutable passes into AvailableAnalysis vector. @@ -277,6 +278,17 @@ public: unsigned getDepth() { return Depth; } +protected: + + // Collection of pass whose last user asked this manager to claim + // last use. If a FunctionPass F is the last user of ModulePass info M + // then the F's manager, not F, records itself as a last user of M. + std::vector<Pass *> ForcedLastUses; + + // Top level manager. + // TODO : Make it a reference. + PMTopLevelManager *TPM; + private: // Set of available Analysis. This information is used while scheduling // pass. If a pass requires an analysis which is not not available then @@ -287,10 +299,6 @@ private: // Collection of pass that are managed by this manager std::vector<Pass *> PassVector; - // Top level manager. - // TODO : Make it a reference. - PMTopLevelManager *TPM; - unsigned Depth; }; @@ -384,7 +392,8 @@ private: /// ModulePassManager_New manages ModulePasses and function pass managers. /// It batches all Module passes passes and function pass managers together and /// sequence them to process one module. -class ModulePassManager_New : public PMDataManager { +class ModulePassManager_New : public Pass, + public PMDataManager { public: ModulePassManager_New(int D) : PMDataManager(D) { @@ -522,6 +531,33 @@ void PMDataManager::addPassToManager(Pass *P, bool ProcessAnalysis) { if (ProcessAnalysis) { + + // At the moment, this pass is the last user of all required passes. + std::vector<Pass *> LastUses; + std::vector<Pass *> RequiredPasses; + unsigned PDepth = this->getDepth(); + + collectRequiredAnalysisPasses(RequiredPasses, P); + for (std::vector<Pass *>::iterator I = RequiredPasses.begin(), + E = RequiredPasses.end(); I != E; ++I) { + Pass *PRequired = *I; + unsigned RDepth = 0; + //FIXME: RDepth = PRequired->getResolver()->getDepth(); + if (PDepth == RDepth) + LastUses.push_back(PRequired); + else if (PDepth > RDepth) { + // Let the parent claim responsibility of last use + ForcedLastUses.push_back(PRequired); + } else { + // Note : This feature is not yet implemented + assert (0 && + "Unable to handle Pass that requires lower level Analysis pass"); + } + } + + if (!LastUses.empty()) + TPM->setLastUser(LastUses, P); + // Take a note of analysis required and made available by this pass. // Remove the analysis not preserved by this pass initializeAnalysisImpl(P); @@ -696,6 +732,10 @@ FunctionPassManagerImpl_New::addPass(Pass *P) { if (!activeBBPassManager->addPass(BP)) assert(0 && "Unable to add Pass"); } + + if (!ForcedLastUses.empty()) + TPM->setLastUser(ForcedLastUses, this); + return true; } @@ -836,6 +876,10 @@ ModulePassManager_New::addPass(Pass *P) { if (!activeFunctionPassManager->addPass(FP)) assert(0 && "Unable to add pass"); } + + if (!ForcedLastUses.empty()) + TPM->setLastUser(ForcedLastUses, this); + return true; } |