Keep track if analysis made available by the pass.

llvm-svn: 31664
This commit is contained in:
Devang Patel 2006-11-11 01:10:19 +00:00
parent e183ed753f
commit 643676c1f5
2 changed files with 30 additions and 5 deletions

View File

@ -19,6 +19,7 @@
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include <vector> #include <vector>
#include <set>
namespace llvm { namespace llvm {
@ -106,9 +107,12 @@ public:
/// Return true IFF AnalysisID AID is currently available. /// Return true IFF AnalysisID AID is currently available.
bool analysisCurrentlyAvailable(AnalysisID AID); 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); void noteDownRequiredAnalysis(Pass *P);
/// Augment AvailableAnalysis by adding analysis made available by pass P.
void noteDownAvailableAnalysis(Pass *P);
/// Remove AnalysisID from the RequiredSet /// Remove AnalysisID from the RequiredSet
void removeAnalysis(AnalysisID AID); void removeAnalysis(AnalysisID AID);
@ -121,6 +125,9 @@ public:
private: private:
// Analysis required by the passes managed by this manager // Analysis required by the passes managed by this manager
std::vector<AnalysisID> RequiredAnalysis; std::vector<AnalysisID> RequiredAnalysis;
// set of available Analysis
std::set<AnalysisID> AvailableAnalysis;
}; };
/// PassManager_New manages ModulePassManagers /// PassManager_New manages ModulePassManagers

View File

@ -164,7 +164,7 @@ bool CommonPassManagerImpl::analysisCurrentlyAvailable(AnalysisID AID) {
return false; 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) { void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) {
AnalysisUsage AnUsage; AnalysisUsage AnUsage;
P->getAnalysisUsage(AnUsage); P->getAnalysisUsage(AnUsage);
@ -174,6 +174,21 @@ void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) {
RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(), RequiredSet.end()); 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<const PassInfo*> &II = PI->getInterfacesImplemented();
//TODO for (unsigned i = 0, e = II.size(); i != e; ++i)
//TODO CurrentAnalyses[II[i]] = P;
}
}
/// Remove AnalysisID from the RequiredSet /// Remove AnalysisID from the RequiredSet
void CommonPassManagerImpl::removeAnalysis(AnalysisID AID) { void CommonPassManagerImpl::removeAnalysis(AnalysisID AID) {
@ -202,8 +217,9 @@ BasicBlockPassManager_New::addPass(Pass *P) {
if (!manageablePass(P)) if (!manageablePass(P))
return false; 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); noteDownRequiredAnalysis(P);
noteDownAvailableAnalysis(P);
// Add pass // Add pass
PassVector.push_back(BP); PassVector.push_back(BP);
@ -285,8 +301,9 @@ FunctionPassManagerImpl_New::addPass(Pass *P) {
if (!manageablePass(P)) if (!manageablePass(P))
return false; 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); noteDownRequiredAnalysis(P);
noteDownAvailableAnalysis(P);
PassVector.push_back(FP); PassVector.push_back(FP);
activeBBPassManager = NULL; activeBBPassManager = NULL;
@ -345,8 +362,9 @@ ModulePassManager_New::addPass(Pass *P) {
if (!manageablePass(P)) if (!manageablePass(P))
return false; 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); noteDownRequiredAnalysis(P);
noteDownAvailableAnalysis(P);
PassVector.push_back(MP); PassVector.push_back(MP);
activeFunctionPassManager = NULL; activeFunctionPassManager = NULL;