forked from OSchip/llvm-project
1) Remove old AnalysisResolver.
2) Rename AnalysisResolver_New as AnalysisResolver llvm-svn: 32938
This commit is contained in:
parent
9329c5f06b
commit
b66334b73b
|
@ -49,7 +49,7 @@ template<class Trait> class PassManagerT;
|
||||||
class BasicBlockPassManager;
|
class BasicBlockPassManager;
|
||||||
class FunctionPassManagerT;
|
class FunctionPassManagerT;
|
||||||
class ModulePassManager;
|
class ModulePassManager;
|
||||||
class AnalysisResolver_New;
|
class AnalysisResolver;
|
||||||
|
|
||||||
// AnalysisID - Use the PassInfo to identify a pass...
|
// AnalysisID - Use the PassInfo to identify a pass...
|
||||||
typedef const PassInfo* AnalysisID;
|
typedef const PassInfo* AnalysisID;
|
||||||
|
@ -60,7 +60,7 @@ typedef const PassInfo* AnalysisID;
|
||||||
/// constrained passes described below.
|
/// constrained passes described below.
|
||||||
///
|
///
|
||||||
class Pass {
|
class Pass {
|
||||||
AnalysisResolver_New *Resolver_New; // Used to resolve analysis
|
AnalysisResolver *Resolver; // Used to resolve analysis
|
||||||
const PassInfo *PassInfoCache;
|
const PassInfo *PassInfoCache;
|
||||||
|
|
||||||
// AnalysisImpls - This keeps track of which passes implement the interfaces
|
// AnalysisImpls - This keeps track of which passes implement the interfaces
|
||||||
|
@ -71,7 +71,7 @@ class Pass {
|
||||||
void operator=(const Pass&); // DO NOT IMPLEMENT
|
void operator=(const Pass&); // DO NOT IMPLEMENT
|
||||||
Pass(const Pass &); // DO NOT IMPLEMENT
|
Pass(const Pass &); // DO NOT IMPLEMENT
|
||||||
public:
|
public:
|
||||||
Pass() : Resolver_New(0), PassInfoCache(0) {}
|
Pass() : Resolver(0), PassInfoCache(0) {}
|
||||||
virtual ~Pass() {} // Destructor is virtual so we can be subclassed
|
virtual ~Pass() {} // Destructor is virtual so we can be subclassed
|
||||||
|
|
||||||
/// getPassName - Return a nice clean name for a pass. This usually
|
/// getPassName - Return a nice clean name for a pass. This usually
|
||||||
|
@ -104,9 +104,9 @@ public:
|
||||||
void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); }
|
void print(std::ostream *O, const Module *M) const { if (O) print(*O, M); }
|
||||||
void dump() const; // dump - call print(std::cerr, 0);
|
void dump() const; // dump - call print(std::cerr, 0);
|
||||||
|
|
||||||
// Access AnalysisResolver_New
|
// Access AnalysisResolver
|
||||||
inline void setResolver(AnalysisResolver_New *AR) { Resolver_New = AR; }
|
inline void setResolver(AnalysisResolver *AR) { Resolver = AR; }
|
||||||
inline AnalysisResolver_New *getResolver() { return Resolver_New; }
|
inline AnalysisResolver *getResolver() { return Resolver; }
|
||||||
|
|
||||||
/// getAnalysisUsage - This function should be overriden by passes that need
|
/// getAnalysisUsage - This function should be overriden by passes that need
|
||||||
/// analysis information to do their job. If a pass specifies that it uses a
|
/// analysis information to do their job. If a pass specifies that it uses a
|
||||||
|
|
|
@ -106,12 +106,12 @@ public:
|
||||||
// the pass.
|
// the pass.
|
||||||
//
|
//
|
||||||
class PMDataManager;
|
class PMDataManager;
|
||||||
class AnalysisResolver_New {
|
class AnalysisResolver {
|
||||||
private:
|
private:
|
||||||
AnalysisResolver_New(); // DO NOT IMPLEMENT
|
AnalysisResolver(); // DO NOT IMPLEMENT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AnalysisResolver_New(PMDataManager &P) : PM(P) { }
|
AnalysisResolver(PMDataManager &P) : PM(P) { }
|
||||||
|
|
||||||
inline PMDataManager &getPMDataManager() { return PM; }
|
inline PMDataManager &getPMDataManager() { return PM; }
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public:
|
||||||
|
|
||||||
// AnalysisImpls - This keeps track of which passes implements the interfaces
|
// AnalysisImpls - This keeps track of which passes implements the interfaces
|
||||||
// that are required by the current pass (to implement getAnalysis()).
|
// that are required by the current pass (to implement getAnalysis()).
|
||||||
// NOTE : Remove AnalysisImpls from class Pass, when AnalysisResolver_New
|
// NOTE : Remove AnalysisImpls from class Pass, when AnalysisResolver
|
||||||
// replaces AnalysisResolver
|
// replaces AnalysisResolver
|
||||||
std::vector<std::pair<const PassInfo*, Pass*> > AnalysisImpls;
|
std::vector<std::pair<const PassInfo*, Pass*> > AnalysisImpls;
|
||||||
|
|
||||||
|
@ -146,37 +146,6 @@ private:
|
||||||
PMDataManager &PM;
|
PMDataManager &PM;
|
||||||
};
|
};
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// AnalysisResolver - Simple interface implemented by PassManager objects that
|
|
||||||
// is used to pull analysis information out of them.
|
|
||||||
//
|
|
||||||
struct AnalysisResolver {
|
|
||||||
virtual ~AnalysisResolver();
|
|
||||||
virtual Pass *getAnalysisOrNullUp(AnalysisID ID) const = 0;
|
|
||||||
virtual Pass *getAnalysisOrNullDown(AnalysisID ID) const = 0;
|
|
||||||
virtual void addPass(ImmutablePass *IP, AnalysisUsage &AU) = 0;
|
|
||||||
Pass *getAnalysis(AnalysisID ID) const {
|
|
||||||
Pass *Result = getAnalysisOrNullUp(ID);
|
|
||||||
assert(Result && "Pass has an incorrect analysis uses set!");
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// getAnalysisToUpdate - Return an analysis result or null if it doesn't exist
|
|
||||||
Pass *getAnalysisToUpdate(AnalysisID ID) const {
|
|
||||||
return getAnalysisOrNullUp(ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methods for introspecting into pass manager objects...
|
|
||||||
virtual unsigned getDepth() const = 0;
|
|
||||||
virtual unsigned getNumContainedPasses() const = 0;
|
|
||||||
virtual const Pass *getContainedPass(unsigned N) const = 0;
|
|
||||||
|
|
||||||
virtual void markPassUsed(AnalysisID P, Pass *User) = 0;
|
|
||||||
|
|
||||||
void startPass(Pass *P) {}
|
|
||||||
void endPass(Pass *P) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses
|
/// getAnalysisToUpdate<AnalysisType>() - This function is used by subclasses
|
||||||
/// to get to the analysis information that might be around that needs to be
|
/// to get to the analysis information that might be around that needs to be
|
||||||
/// updated. This is different than getAnalysis in that it can fail (ie the
|
/// updated. This is different than getAnalysis in that it can fail (ie the
|
||||||
|
@ -187,12 +156,12 @@ struct AnalysisResolver {
|
||||||
///
|
///
|
||||||
template<typename AnalysisType>
|
template<typename AnalysisType>
|
||||||
AnalysisType *Pass::getAnalysisToUpdate() const {
|
AnalysisType *Pass::getAnalysisToUpdate() const {
|
||||||
assert(Resolver_New && "Pass not resident in a PassManager object!");
|
assert(Resolver && "Pass not resident in a PassManager object!");
|
||||||
|
|
||||||
const PassInfo *PI = getClassPassInfo<AnalysisType>();
|
const PassInfo *PI = getClassPassInfo<AnalysisType>();
|
||||||
if (PI == 0) return 0;
|
if (PI == 0) return 0;
|
||||||
return dynamic_cast<AnalysisType*>
|
return dynamic_cast<AnalysisType*>
|
||||||
(Resolver_New->getAnalysisToUpdate(PI, true));
|
(Resolver->getAnalysisToUpdate(PI, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
|
/// getAnalysis<AnalysisType>() - This function is used by subclasses to get
|
||||||
|
@ -201,7 +170,7 @@ AnalysisType *Pass::getAnalysisToUpdate() const {
|
||||||
///
|
///
|
||||||
template<typename AnalysisType>
|
template<typename AnalysisType>
|
||||||
AnalysisType &Pass::getAnalysis() const {
|
AnalysisType &Pass::getAnalysis() const {
|
||||||
assert(Resolver_New &&"Pass has not been inserted into a PassManager object!");
|
assert(Resolver &&"Pass has not been inserted into a PassManager object!");
|
||||||
|
|
||||||
return getAnalysisID<AnalysisType>(getClassPassInfo<AnalysisType>());
|
return getAnalysisID<AnalysisType>(getClassPassInfo<AnalysisType>());
|
||||||
}
|
}
|
||||||
|
@ -209,11 +178,11 @@ AnalysisType &Pass::getAnalysis() const {
|
||||||
template<typename AnalysisType>
|
template<typename AnalysisType>
|
||||||
AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const {
|
AnalysisType &Pass::getAnalysisID(const PassInfo *PI) const {
|
||||||
assert(PI && "getAnalysis for unregistered pass!");
|
assert(PI && "getAnalysis for unregistered pass!");
|
||||||
assert(Resolver_New&&"Pass has not been inserted into a PassManager object!");
|
assert(Resolver&&"Pass has not been inserted into a PassManager object!");
|
||||||
// PI *must* appear in AnalysisImpls. Because the number of passes used
|
// PI *must* appear in AnalysisImpls. Because the number of passes used
|
||||||
// should be a small number, we just do a linear search over a (dense)
|
// should be a small number, we just do a linear search over a (dense)
|
||||||
// vector.
|
// vector.
|
||||||
Pass *ResultPass = Resolver_New->findImplPass(PI);
|
Pass *ResultPass = Resolver->findImplPass(PI);
|
||||||
assert (ResultPass &&
|
assert (ResultPass &&
|
||||||
"getAnalysis*() called on an analysis that was not "
|
"getAnalysis*() called on an analysis that was not "
|
||||||
"'required' by pass!");
|
"'required' by pass!");
|
||||||
|
|
|
@ -22,13 +22,6 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// AnalysisResolver Class Implementation
|
|
||||||
//
|
|
||||||
|
|
||||||
AnalysisResolver::~AnalysisResolver() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Pass Implementation
|
// Pass Implementation
|
||||||
//
|
//
|
||||||
|
@ -37,7 +30,7 @@ AnalysisResolver::~AnalysisResolver() {
|
||||||
ModulePass::~ModulePass() { }
|
ModulePass::~ModulePass() { }
|
||||||
|
|
||||||
bool Pass::mustPreserveAnalysisID(const PassInfo *AnalysisID) const {
|
bool Pass::mustPreserveAnalysisID(const PassInfo *AnalysisID) const {
|
||||||
return Resolver_New->getAnalysisToUpdate(AnalysisID, true) != 0;
|
return Resolver->getAnalysisToUpdate(AnalysisID, true) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dumpPassStructure - Implement the -debug-passes=Structure option
|
// dumpPassStructure - Implement the -debug-passes=Structure option
|
||||||
|
|
|
@ -463,7 +463,7 @@ public:
|
||||||
|
|
||||||
// P is a immutable pass and it will be managed by this
|
// P is a immutable pass and it will be managed by this
|
||||||
// top level manager. Set up analysis resolver to connect them.
|
// top level manager. Set up analysis resolver to connect them.
|
||||||
AnalysisResolver_New *AR = new AnalysisResolver_New(*this);
|
AnalysisResolver *AR = new AnalysisResolver(*this);
|
||||||
P->setResolver(AR);
|
P->setResolver(AR);
|
||||||
initializeAnalysisImpl(P);
|
initializeAnalysisImpl(P);
|
||||||
addImmutablePass(IP);
|
addImmutablePass(IP);
|
||||||
|
@ -571,7 +571,7 @@ public:
|
||||||
|
|
||||||
// P is a immutable pass and it will be managed by this
|
// P is a immutable pass and it will be managed by this
|
||||||
// top level manager. Set up analysis resolver to connect them.
|
// top level manager. Set up analysis resolver to connect them.
|
||||||
AnalysisResolver_New *AR = new AnalysisResolver_New(*this);
|
AnalysisResolver *AR = new AnalysisResolver(*this);
|
||||||
P->setResolver(AR);
|
P->setResolver(AR);
|
||||||
initializeAnalysisImpl(P);
|
initializeAnalysisImpl(P);
|
||||||
addImmutablePass(IP);
|
addImmutablePass(IP);
|
||||||
|
@ -873,7 +873,7 @@ void PMDataManager::addPassToManager(Pass *P,
|
||||||
|
|
||||||
// This manager is going to manage pass P. Set up analysis resolver
|
// This manager is going to manage pass P. Set up analysis resolver
|
||||||
// to connect them.
|
// to connect them.
|
||||||
AnalysisResolver_New *AR = new AnalysisResolver_New(*this);
|
AnalysisResolver *AR = new AnalysisResolver(*this);
|
||||||
P->setResolver(AR);
|
P->setResolver(AR);
|
||||||
|
|
||||||
if (ProcessAnalysis) {
|
if (ProcessAnalysis) {
|
||||||
|
@ -956,7 +956,7 @@ void PMDataManager::initializeAnalysisImpl(Pass *P) {
|
||||||
Pass *Impl = findAnalysisPass(*I, true);
|
Pass *Impl = findAnalysisPass(*I, true);
|
||||||
if (Impl == 0)
|
if (Impl == 0)
|
||||||
assert(0 && "Analysis used but not available!");
|
assert(0 && "Analysis used but not available!");
|
||||||
AnalysisResolver_New *AR = P->getResolver();
|
AnalysisResolver *AR = P->getResolver();
|
||||||
AR->addAnalysisImplsPair(*I, Impl);
|
AR->addAnalysisImplsPair(*I, Impl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1031,7 +1031,7 @@ void PMDataManager::dumpAnalysisSetInfo(const char *Msg, Pass *P,
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// NOTE: Is this the right place to define this method ?
|
// NOTE: Is this the right place to define this method ?
|
||||||
// getAnalysisToUpdate - Return an analysis result or null if it doesn't exist
|
// getAnalysisToUpdate - Return an analysis result or null if it doesn't exist
|
||||||
Pass *AnalysisResolver_New::getAnalysisToUpdate(AnalysisID ID, bool dir) const {
|
Pass *AnalysisResolver::getAnalysisToUpdate(AnalysisID ID, bool dir) const {
|
||||||
return PM.findAnalysisPass(ID, dir);
|
return PM.findAnalysisPass(ID, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1154,7 +1154,7 @@ FunctionPassManager::FunctionPassManager(ModuleProvider *P) {
|
||||||
FPM->setTopLevelManager(FPM);
|
FPM->setTopLevelManager(FPM);
|
||||||
|
|
||||||
PMDataManager *PMD = dynamic_cast<PMDataManager *>(FPM);
|
PMDataManager *PMD = dynamic_cast<PMDataManager *>(FPM);
|
||||||
AnalysisResolver_New *AR = new AnalysisResolver_New(*PMD);
|
AnalysisResolver *AR = new AnalysisResolver(*PMD);
|
||||||
FPM->setResolver(AR);
|
FPM->setResolver(AR);
|
||||||
|
|
||||||
MP = P;
|
MP = P;
|
||||||
|
@ -1213,7 +1213,7 @@ bool FunctionPassManagerImpl::addPass(Pass *P) {
|
||||||
|
|
||||||
// This top level manager is going to manage activeManager.
|
// This top level manager is going to manage activeManager.
|
||||||
// Set up analysis resolver to connect them.
|
// Set up analysis resolver to connect them.
|
||||||
AnalysisResolver_New *AR = new AnalysisResolver_New(*this);
|
AnalysisResolver *AR = new AnalysisResolver(*this);
|
||||||
activeManager->setResolver(AR);
|
activeManager->setResolver(AR);
|
||||||
|
|
||||||
addPassManager(activeManager);
|
addPassManager(activeManager);
|
||||||
|
@ -1520,7 +1520,7 @@ bool PassManagerImpl::addPass(Pass *P) {
|
||||||
|
|
||||||
// This top level manager is going to manage activeManager.
|
// This top level manager is going to manage activeManager.
|
||||||
// Set up analysis resolver to connect them.
|
// Set up analysis resolver to connect them.
|
||||||
AnalysisResolver_New *AR = new AnalysisResolver_New(*this);
|
AnalysisResolver *AR = new AnalysisResolver(*this);
|
||||||
activeManager->setResolver(AR);
|
activeManager->setResolver(AR);
|
||||||
|
|
||||||
addPassManager(activeManager);
|
addPassManager(activeManager);
|
||||||
|
|
Loading…
Reference in New Issue