- if (Parent == 0) PMDebug::PerformPassStartupStuff(this);
-
- // Run all of the passes
- for (unsigned i = 0, e = Passes.size(); i < e; ++i) {
- PassClass *P = Passes[i];
-
- PMDebug::PrintPassInformation(getDepth(), "Executing Pass", P, M);
-
- // Get information about what analyses the pass uses...
- AnalysisUsage AnUsage;
- P->getAnalysisUsage(AnUsage);
- PMDebug::PrintAnalysisSetInfo(getDepth(), "Required", P,
- AnUsage.getRequiredSet());
-
- // All Required analyses should be available to the pass as it runs! Here
- // we fill in the AnalysisImpls member of the pass so that it can
- // successfully use the getAnalysis() method to retrieve the
- // implementations it needs.
- //
- P->AnalysisImpls.clear();
- P->AnalysisImpls.reserve(AnUsage.getRequiredSet().size());
- for (std::vector<const PassInfo *>::const_iterator
- I = AnUsage.getRequiredSet().begin(),
- E = AnUsage.getRequiredSet().end(); I != E; ++I) {
- Pass *Impl = getAnalysisOrNullUp(*I);
- if (Impl == 0) {
- std::cerr << "Analysis '" << (*I)->getPassName()
- << "' used but not available!";
- assert(0 && "Analysis used but not available!");
- } else if (PassDebugging == Details) {
- if ((*I)->getPassName() != std::string(Impl->getPassName()))
- std::cerr << " Interface '" << (*I)->getPassName()
- << "' implemented by '" << Impl->getPassName() << "'\n";
- }
- P->AnalysisImpls.push_back(std::make_pair(*I, Impl));
- }
-
- // Run the sub pass!
- if (TheTimeInfo) TheTimeInfo->passStarted(P);
- bool Changed = runPass(P, M);
- if (TheTimeInfo) TheTimeInfo->passEnded(P);
- MadeChanges |= Changed;
-
- // Check for memory leaks by the pass...
- LeakDetector::checkForGarbage(std::string("after running pass '") +
- P->getPassName() + "'");
-
- if (Changed)
- PMDebug::PrintPassInformation(getDepth()+1, "Made Modification", P, M);
- PMDebug::PrintAnalysisSetInfo(getDepth(), "Preserved", P,
- AnUsage.getPreservedSet());
-
-
- // Erase all analyses not in the preserved set...
- if (!AnUsage.getPreservesAll()) {
- const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
- for (std::map<AnalysisID, Pass*>::iterator I = CurrentAnalyses.begin(),
- E = CurrentAnalyses.end(); I != E; )
- if (std::find(PreservedSet.begin(), PreservedSet.end(), I->first) !=
- PreservedSet.end())
- ++I; // This analysis is preserved, leave it in the available set...
- else {
- if (!dynamic_cast<ImmutablePass*>(I->second)) {
- std::map<AnalysisID, Pass*>::iterator J = I++;
- CurrentAnalyses.erase(J); // Analysis not preserved!
- } else {
- ++I;
- }
- }
- }
-
- // Add the current pass to the set of passes that have been run, and are
- // thus available to users.
- //
- if (const PassInfo *PI = P->getPassInfo()) {
- CurrentAnalyses[PI] = P;