From b8526162551a3fbcf787e01d82ef44b69f879e01 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Sat, 11 Nov 2006 01:10:19 +0000 Subject: [PATCH] Keep track if analysis made available by the pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31664 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/PassManager.h | 9 ++++++++- lib/VMCore/PassManager.cpp | 26 ++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index 075a572fb33..667fa7050af 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -19,6 +19,7 @@ #include "llvm/Pass.h" #include +#include namespace llvm { @@ -106,9 +107,12 @@ public: /// Return true IFF AnalysisID AID is currently available. bool analysisCurrentlyAvailable(AnalysisID AID); - /// Augment RequiredSet by adding analysis required by pass P. + /// Augment RequiredAnalysis by adding analysis required by pass P. void noteDownRequiredAnalysis(Pass *P); + /// Augment AvailableAnalysis by adding analysis made available by pass P. + void noteDownAvailableAnalysis(Pass *P); + /// Remove AnalysisID from the RequiredSet void removeAnalysis(AnalysisID AID); @@ -121,6 +125,9 @@ public: private: // Analysis required by the passes managed by this manager std::vector RequiredAnalysis; + + // set of available Analysis + std::set AvailableAnalysis; }; /// PassManager_New manages ModulePassManagers diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 27a86b65a68..157a9aa56e6 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -164,7 +164,7 @@ bool CommonPassManagerImpl::analysisCurrentlyAvailable(AnalysisID AID) { return false; } -/// Augment RequiredSet by adding analysis required by pass P. +/// Augment RequiredAnalysis by adding analysis required by pass P. void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) { AnalysisUsage AnUsage; P->getAnalysisUsage(AnUsage); @@ -174,6 +174,21 @@ void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) { RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(), RequiredSet.end()); } +/// Augement AvailableAnalysis by adding analysis made available by pass P. +void CommonPassManagerImpl::noteDownAvailableAnalysis(Pass *P) { + + if (const PassInfo *PI = P->getPassInfo()) { + AvailableAnalysis.insert(PI); + + //TODO This pass is the current implementation of all of the interfaces it + //TODO implements as well. + //TODO + //TODO const std::vector &II = PI->getInterfacesImplemented(); + //TODO for (unsigned i = 0, e = II.size(); i != e; ++i) + //TODO CurrentAnalyses[II[i]] = P; + } +} + /// Remove AnalysisID from the RequiredSet void CommonPassManagerImpl::removeAnalysis(AnalysisID AID) { @@ -202,8 +217,9 @@ BasicBlockPassManager_New::addPass(Pass *P) { if (!manageablePass(P)) return false; - // Take a note of analysis required by this pass. + // Take a note of analysis required and made available by this pass noteDownRequiredAnalysis(P); + noteDownAvailableAnalysis(P); // Add pass PassVector.push_back(BP); @@ -285,8 +301,9 @@ FunctionPassManagerImpl_New::addPass(Pass *P) { if (!manageablePass(P)) return false; - // Take a note of analysis required by this pass. + // Take a note of analysis required and made available by this pass noteDownRequiredAnalysis(P); + noteDownAvailableAnalysis(P); PassVector.push_back(FP); activeBBPassManager = NULL; @@ -345,8 +362,9 @@ ModulePassManager_New::addPass(Pass *P) { if (!manageablePass(P)) return false; - // Take a note of analysis required by this pass. + // Take a note of analysis required and made available by this pass noteDownRequiredAnalysis(P); + noteDownAvailableAnalysis(P); PassVector.push_back(MP); activeFunctionPassManager = NULL;