[llvm-commits] [llvm] r48315 - in /llvm/trunk: include/llvm/PassManagers.h lib/VMCore/PassManager.cpp
Dan Gohman
gohman at apple.com
Wed Mar 12 18:48:32 PDT 2008
Author: djg
Date: Wed Mar 12 20:48:32 2008
New Revision: 48315
URL: http://llvm.org/viewvc/llvm-project?rev=48315&view=rev
Log:
Change PMTopLevelManager's PassManagers vector element type from
Pass* to PMDataManager*. PMDataManager is more specific than Pass,
so this more accurately describes the objects that are being stored.
This eliminates the need for several dynamic_casts to PMDataManager*.
It does introduce one dynamic_cast though, in dumpPasses(). Give
this one a comment describing why a dynamic_cast is being used.
Modified:
llvm/trunk/include/llvm/PassManagers.h
llvm/trunk/lib/VMCore/PassManager.cpp
Modified: llvm/trunk/include/llvm/PassManagers.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=48315&r1=48314&r2=48315&view=diff
==============================================================================
--- llvm/trunk/include/llvm/PassManagers.h (original)
+++ llvm/trunk/include/llvm/PassManagers.h Wed Mar 12 20:48:32 2008
@@ -150,7 +150,7 @@
return ImmutablePasses;
}
- void addPassManager(Pass *Manager) {
+ void addPassManager(PMDataManager *Manager) {
PassManagers.push_back(Manager);
}
@@ -172,7 +172,7 @@
protected:
/// Collection of pass managers
- std::vector<Pass *> PassManagers;
+ std::vector<PMDataManager *> PassManagers;
private:
Modified: llvm/trunk/lib/VMCore/PassManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=48315&r1=48314&r2=48315&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/PassManager.cpp (original)
+++ llvm/trunk/lib/VMCore/PassManager.cpp Wed Mar 12 20:48:32 2008
@@ -455,10 +455,9 @@
Pass *P = NULL;
// Check pass managers
- for (std::vector<Pass *>::iterator I = PassManagers.begin(),
+ for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(),
E = PassManagers.end(); P == NULL && I != E; ++I) {
- PMDataManager *PMD = dynamic_cast<PMDataManager *>(*I);
- assert(PMD && "This is not a PassManager");
+ PMDataManager *PMD = *I;
P = PMD->findAnalysisPass(AID, false);
}
@@ -496,9 +495,13 @@
ImmutablePasses[i]->dumpPassStructure(0);
}
- for (std::vector<Pass *>::const_iterator I = PassManagers.begin(),
+ // Every class that derives from PMDataManager also derives from Pass
+ // (sometimes indirectly), but there's no inheritance relationship
+ // between PMDataManager and Pass, so we have to dynamic_cast to get
+ // from a PMDataManager* to a Pass*.
+ for (std::vector<PMDataManager *>::const_iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I)
- (*I)->dumpPassStructure(1);
+ dynamic_cast<Pass *>(*I)->dumpPassStructure(1);
}
void PMTopLevelManager::dumpArguments() const {
@@ -507,10 +510,9 @@
return;
cerr << "Pass Arguments: ";
- for (std::vector<Pass *>::const_iterator I = PassManagers.begin(),
+ for (std::vector<PMDataManager *>::const_iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I) {
- PMDataManager *PMD = dynamic_cast<PMDataManager *>(*I);
- assert(PMD && "This is not a PassManager");
+ PMDataManager *PMD = *I;
PMD->dumpPassArguments();
}
cerr << "\n";
@@ -518,10 +520,9 @@
void PMTopLevelManager::initializeAllAnalysisInfo() {
- for (std::vector<Pass *>::iterator I = PassManagers.begin(),
+ for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I) {
- PMDataManager *PMD = dynamic_cast<PMDataManager *>(*I);
- assert(PMD && "This is not a PassManager");
+ PMDataManager *PMD = *I;
PMD->initializeAnalysisInfo();
}
@@ -533,7 +534,7 @@
/// Destructor
PMTopLevelManager::~PMTopLevelManager() {
- for (std::vector<Pass *>::iterator I = PassManagers.begin(),
+ for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(),
E = PassManagers.end(); I != E; ++I)
delete *I;
More information about the llvm-commits
mailing list