eliminate a bunch of dynamic_cast's.

llvm-svn: 94154
This commit is contained in:
Chris Lattner 2010-01-22 04:55:08 +00:00
parent a1293a67cd
commit 21889d7337
2 changed files with 9 additions and 9 deletions

View File

@ -152,6 +152,7 @@ public:
virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
return this;
}
virtual ImmutablePass *getAsImmutablePass() { return 0; }
/// verifyAnalysis() - This member can be implemented by a analysis pass to
/// check state of analysis information.
@ -249,6 +250,8 @@ public:
///
virtual void initializePass();
virtual ImmutablePass *getAsImmutablePass() { return this; }
/// ImmutablePasses are never run.
///
bool runOnModule(Module &) { return false; }

View File

@ -202,9 +202,7 @@ public:
}
inline void addTopLevelPass(Pass *P) {
if (ImmutablePass *IP = dynamic_cast<ImmutablePass *> (P)) {
if (ImmutablePass *IP = P->getAsImmutablePass()) {
// P is a immutable pass and it will be managed by this
// top level manager. Set up analysis resolver to connect them.
AnalysisResolver *AR = new AnalysisResolver(*this);
@ -333,8 +331,7 @@ public:
}
inline void addTopLevelPass(Pass *P) {
if (ImmutablePass *IP = dynamic_cast<ImmutablePass *> (P)) {
if (ImmutablePass *IP = P->getAsImmutablePass()) {
// P is a immutable pass and it will be managed by this
// top level manager. Set up analysis resolver to connect them.
AnalysisResolver *AR = new AnalysisResolver(*this);
@ -670,7 +667,7 @@ bool PMDataManager::preserveHigherLevelAnalysis(Pass *P) {
for (SmallVector<Pass *, 8>::iterator I = HigherLevelAnalysis.begin(),
E = HigherLevelAnalysis.end(); I != E; ++I) {
Pass *P1 = *I;
if (!dynamic_cast<ImmutablePass*>(P1) &&
if (P1->getAsImmutablePass() == 0 &&
std::find(PreservedSet.begin(), PreservedSet.end(),
P1->getPassInfo()) ==
PreservedSet.end())
@ -713,8 +710,8 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
for (std::map<AnalysisID, Pass*>::iterator I = AvailableAnalysis.begin(),
E = AvailableAnalysis.end(); I != E; ) {
std::map<AnalysisID, Pass*>::iterator Info = I++;
if (!dynamic_cast<ImmutablePass*>(Info->second)
&& std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) ==
if (Info->second->getAsImmutablePass() == 0 &&
std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) ==
PreservedSet.end()) {
// Remove this analysis
if (PassDebugging >= Details) {
@ -737,7 +734,7 @@ void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
I = InheritedAnalysis[Index]->begin(),
E = InheritedAnalysis[Index]->end(); I != E; ) {
std::map<AnalysisID, Pass *>::iterator Info = I++;
if (!dynamic_cast<ImmutablePass*>(Info->second) &&
if (Info->second->getAsImmutablePass() == 0 &&
std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) ==
PreservedSet.end()) {
// Remove this analysis