diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h index 44c932a0c60..eaa6f442709 100644 --- a/include/llvm/PassManagers.h +++ b/include/llvm/PassManagers.h @@ -150,7 +150,7 @@ public: return ImmutablePasses; } - void addPassManager(Pass *Manager) { + void addPassManager(PMDataManager *Manager) { PassManagers.push_back(Manager); } @@ -172,7 +172,7 @@ public: protected: /// Collection of pass managers - std::vector PassManagers; + std::vector PassManagers; private: diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index 275e0aea3fe..614ace31586 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -455,10 +455,9 @@ Pass *PMTopLevelManager::findAnalysisPass(AnalysisID AID) { Pass *P = NULL; // Check pass managers - for (std::vector::iterator I = PassManagers.begin(), + for (std::vector::iterator I = PassManagers.begin(), E = PassManagers.end(); P == NULL && I != E; ++I) { - PMDataManager *PMD = dynamic_cast(*I); - assert(PMD && "This is not a PassManager"); + PMDataManager *PMD = *I; P = PMD->findAnalysisPass(AID, false); } @@ -496,9 +495,13 @@ void PMTopLevelManager::dumpPasses() const { ImmutablePasses[i]->dumpPassStructure(0); } - for (std::vector::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::const_iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) - (*I)->dumpPassStructure(1); + dynamic_cast(*I)->dumpPassStructure(1); } void PMTopLevelManager::dumpArguments() const { @@ -507,10 +510,9 @@ void PMTopLevelManager::dumpArguments() const { return; cerr << "Pass Arguments: "; - for (std::vector::const_iterator I = PassManagers.begin(), + for (std::vector::const_iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) { - PMDataManager *PMD = dynamic_cast(*I); - assert(PMD && "This is not a PassManager"); + PMDataManager *PMD = *I; PMD->dumpPassArguments(); } cerr << "\n"; @@ -518,10 +520,9 @@ void PMTopLevelManager::dumpArguments() const { void PMTopLevelManager::initializeAllAnalysisInfo() { - for (std::vector::iterator I = PassManagers.begin(), + for (std::vector::iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) { - PMDataManager *PMD = dynamic_cast(*I); - assert(PMD && "This is not a PassManager"); + PMDataManager *PMD = *I; PMD->initializeAnalysisInfo(); } @@ -533,7 +534,7 @@ void PMTopLevelManager::initializeAllAnalysisInfo() { /// Destructor PMTopLevelManager::~PMTopLevelManager() { - for (std::vector::iterator I = PassManagers.begin(), + for (std::vector::iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) delete *I;