1 //===- PassManager.cpp - LLVM Pass Infrastructure Implementation ----------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the LLVM Pass Manager infrastructure.
12 //===----------------------------------------------------------------------===//
15 #include "llvm/PassManagers.h"
16 #include "llvm/Support/CommandLine.h"
17 #include "llvm/Support/Timer.h"
18 #include "llvm/Module.h"
19 #include "llvm/ModuleProvider.h"
20 #include "llvm/Support/Streams.h"
21 #include "llvm/Support/ManagedStatic.h"
27 // See PassManagers.h for Pass Manager infrastructure overview.
31 //===----------------------------------------------------------------------===//
32 // Pass debugging information. Often it is useful to find out what pass is
33 // running when a crash occurs in a utility. When this library is compiled with
34 // debugging on, a command line option (--debug-pass) is enabled that causes the
35 // pass name to be printed before it executes.
38 // Different debug levels that can be enabled...
40 None, Arguments, Structure, Executions, Details
43 static cl::opt<enum PassDebugLevel>
44 PassDebugging("debug-pass", cl::Hidden,
45 cl::desc("Print PassManager debugging information"),
47 clEnumVal(None , "disable debug output"),
48 clEnumVal(Arguments , "print pass arguments to pass to 'opt'"),
49 clEnumVal(Structure , "print pass structure before run()"),
50 clEnumVal(Executions, "print pass name before it is executed"),
51 clEnumVal(Details , "print pass details when it is executed"),
53 } // End of llvm namespace
57 //===----------------------------------------------------------------------===//
60 /// BBPassManager manages BasicBlockPass. It batches all the
61 /// pass together and sequence them to process one basic block before
62 /// processing next basic block.
63 class VISIBILITY_HIDDEN BBPassManager : public PMDataManager,
68 explicit BBPassManager(int Depth)
69 : PMDataManager(Depth), FunctionPass((intptr_t)&ID) {}
71 /// Execute all of the passes scheduled for execution. Keep track of
72 /// whether any of the passes modifies the function, and if so, return true.
73 bool runOnFunction(Function &F);
75 /// Pass Manager itself does not invalidate any analysis info.
76 void getAnalysisUsage(AnalysisUsage &Info) const {
77 Info.setPreservesAll();
80 bool doInitialization(Module &M);
81 bool doInitialization(Function &F);
82 bool doFinalization(Module &M);
83 bool doFinalization(Function &F);
85 virtual const char *getPassName() const {
86 return "BasicBlock Pass Manager";
89 // Print passes managed by this manager
90 void dumpPassStructure(unsigned Offset) {
91 llvm::cerr << std::string(Offset*2, ' ') << "BasicBlockPass Manager\n";
92 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
93 BasicBlockPass *BP = getContainedPass(Index);
94 BP->dumpPassStructure(Offset + 1);
95 dumpLastUses(BP, Offset+1);
99 BasicBlockPass *getContainedPass(unsigned N) {
100 assert ( N < PassVector.size() && "Pass number out of range!");
101 BasicBlockPass *BP = static_cast<BasicBlockPass *>(PassVector[N]);
105 virtual PassManagerType getPassManagerType() const {
106 return PMT_BasicBlockPassManager;
110 char BBPassManager::ID = 0;
115 //===----------------------------------------------------------------------===//
116 // FunctionPassManagerImpl
118 /// FunctionPassManagerImpl manages FPPassManagers
119 class FunctionPassManagerImpl : public Pass,
120 public PMDataManager,
121 public PMTopLevelManager {
124 explicit FunctionPassManagerImpl(int Depth) :
125 Pass((intptr_t)&ID), PMDataManager(Depth),
126 PMTopLevelManager(TLM_Function) { }
128 /// add - Add a pass to the queue of passes to run. This passes ownership of
129 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
130 /// will be destroyed as well, so there is no need to delete the pass. This
131 /// implies that all passes MUST be allocated with 'new'.
136 /// run - Execute all of the passes scheduled for execution. Keep track of
137 /// whether any of the passes modifies the module, and if so, return true.
138 bool run(Function &F);
140 /// doInitialization - Run all of the initializers for the function passes.
142 bool doInitialization(Module &M);
144 /// doFinalization - Run all of the finalizers for the function passes.
146 bool doFinalization(Module &M);
148 /// Pass Manager itself does not invalidate any analysis info.
149 void getAnalysisUsage(AnalysisUsage &Info) const {
150 Info.setPreservesAll();
153 inline void addTopLevelPass(Pass *P) {
155 if (ImmutablePass *IP = dynamic_cast<ImmutablePass *> (P)) {
157 // P is a immutable pass and it will be managed by this
158 // top level manager. Set up analysis resolver to connect them.
159 AnalysisResolver *AR = new AnalysisResolver(*this);
161 initializeAnalysisImpl(P);
162 addImmutablePass(IP);
163 recordAvailableAnalysis(IP);
165 P->assignPassManager(activeStack);
170 FPPassManager *getContainedManager(unsigned N) {
171 assert ( N < PassManagers.size() && "Pass number out of range!");
172 FPPassManager *FP = static_cast<FPPassManager *>(PassManagers[N]);
177 char FunctionPassManagerImpl::ID = 0;
178 //===----------------------------------------------------------------------===//
181 /// MPPassManager manages ModulePasses and function pass managers.
182 /// It batches all Module passes and function pass managers together and
183 /// sequences them to process one module.
184 class MPPassManager : public Pass, public PMDataManager {
188 explicit MPPassManager(int Depth) :
189 Pass((intptr_t)&ID), PMDataManager(Depth) { }
191 // Delete on the fly managers.
192 virtual ~MPPassManager() {
193 for (std::map<Pass *, FunctionPassManagerImpl *>::iterator
194 I = OnTheFlyManagers.begin(), E = OnTheFlyManagers.end();
196 FunctionPassManagerImpl *FPP = I->second;
201 /// run - Execute all of the passes scheduled for execution. Keep track of
202 /// whether any of the passes modifies the module, and if so, return true.
203 bool runOnModule(Module &M);
205 /// Pass Manager itself does not invalidate any analysis info.
206 void getAnalysisUsage(AnalysisUsage &Info) const {
207 Info.setPreservesAll();
210 /// Add RequiredPass into list of lower level passes required by pass P.
211 /// RequiredPass is run on the fly by Pass Manager when P requests it
212 /// through getAnalysis interface.
213 virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass);
215 /// Return function pass corresponding to PassInfo PI, that is
216 /// required by module pass MP. Instantiate analysis pass, by using
217 /// its runOnFunction() for function F.
218 virtual Pass* getOnTheFlyPass(Pass *MP, const PassInfo *PI, Function &F);
220 virtual const char *getPassName() const {
221 return "Module Pass Manager";
224 // Print passes managed by this manager
225 void dumpPassStructure(unsigned Offset) {
226 llvm::cerr << std::string(Offset*2, ' ') << "ModulePass Manager\n";
227 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
228 ModulePass *MP = getContainedPass(Index);
229 MP->dumpPassStructure(Offset + 1);
230 if (FunctionPassManagerImpl *FPP = OnTheFlyManagers[MP])
231 FPP->dumpPassStructure(Offset + 2);
232 dumpLastUses(MP, Offset+1);
236 ModulePass *getContainedPass(unsigned N) {
237 assert ( N < PassVector.size() && "Pass number out of range!");
238 ModulePass *MP = static_cast<ModulePass *>(PassVector[N]);
242 virtual PassManagerType getPassManagerType() const {
243 return PMT_ModulePassManager;
247 /// Collection of on the fly FPPassManagers. These managers manage
248 /// function passes that are required by module passes.
249 std::map<Pass *, FunctionPassManagerImpl *> OnTheFlyManagers;
252 char MPPassManager::ID = 0;
253 //===----------------------------------------------------------------------===//
257 /// PassManagerImpl manages MPPassManagers
258 class PassManagerImpl : public Pass,
259 public PMDataManager,
260 public PMTopLevelManager {
264 explicit PassManagerImpl(int Depth) :
265 Pass((intptr_t)&ID), PMDataManager(Depth),
266 PMTopLevelManager(TLM_Pass) { }
268 /// add - Add a pass to the queue of passes to run. This passes ownership of
269 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
270 /// will be destroyed as well, so there is no need to delete the pass. This
271 /// implies that all passes MUST be allocated with 'new'.
276 /// run - Execute all of the passes scheduled for execution. Keep track of
277 /// whether any of the passes modifies the module, and if so, return true.
280 /// Pass Manager itself does not invalidate any analysis info.
281 void getAnalysisUsage(AnalysisUsage &Info) const {
282 Info.setPreservesAll();
285 inline void addTopLevelPass(Pass *P) {
287 if (ImmutablePass *IP = dynamic_cast<ImmutablePass *> (P)) {
289 // P is a immutable pass and it will be managed by this
290 // top level manager. Set up analysis resolver to connect them.
291 AnalysisResolver *AR = new AnalysisResolver(*this);
293 initializeAnalysisImpl(P);
294 addImmutablePass(IP);
295 recordAvailableAnalysis(IP);
297 P->assignPassManager(activeStack);
302 MPPassManager *getContainedManager(unsigned N) {
303 assert ( N < PassManagers.size() && "Pass number out of range!");
304 MPPassManager *MP = static_cast<MPPassManager *>(PassManagers[N]);
310 char PassManagerImpl::ID = 0;
311 } // End of llvm namespace
315 //===----------------------------------------------------------------------===//
316 // TimingInfo Class - This class is used to calculate information about the
317 // amount of time each pass takes to execute. This only happens when
318 // -time-passes is enabled on the command line.
321 class VISIBILITY_HIDDEN TimingInfo {
322 std::map<Pass*, Timer> TimingData;
326 // Use 'create' member to get this.
327 TimingInfo() : TG("... Pass execution timing report ...") {}
329 // TimingDtor - Print out information about timing information
331 // Delete all of the timers...
333 // TimerGroup is deleted next, printing the report.
336 // createTheTimeInfo - This method either initializes the TheTimeInfo pointer
337 // to a non null value (if the -time-passes option is enabled) or it leaves it
338 // null. It may be called multiple times.
339 static void createTheTimeInfo();
341 void passStarted(Pass *P) {
343 if (dynamic_cast<PMDataManager *>(P))
346 std::map<Pass*, Timer>::iterator I = TimingData.find(P);
347 if (I == TimingData.end())
348 I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first;
349 I->second.startTimer();
351 void passEnded(Pass *P) {
353 if (dynamic_cast<PMDataManager *>(P))
356 std::map<Pass*, Timer>::iterator I = TimingData.find(P);
357 assert (I != TimingData.end() && "passStarted/passEnded not nested right!");
358 I->second.stopTimer();
362 static TimingInfo *TheTimeInfo;
364 } // End of anon namespace
366 //===----------------------------------------------------------------------===//
367 // PMTopLevelManager implementation
369 /// Initialize top level manager. Create first pass manager.
370 PMTopLevelManager::PMTopLevelManager (enum TopLevelManagerType t) {
373 MPPassManager *MPP = new MPPassManager(1);
374 MPP->setTopLevelManager(this);
376 activeStack.push(MPP);
378 else if (t == TLM_Function) {
379 FPPassManager *FPP = new FPPassManager(1);
380 FPP->setTopLevelManager(this);
382 activeStack.push(FPP);
386 /// Set pass P as the last user of the given analysis passes.
387 void PMTopLevelManager::setLastUser(SmallVector<Pass *, 12> &AnalysisPasses,
390 for (SmallVector<Pass *, 12>::iterator I = AnalysisPasses.begin(),
391 E = AnalysisPasses.end(); I != E; ++I) {
398 // If AP is the last user of other passes then make P last user of
400 for (std::map<Pass *, Pass *>::iterator LUI = LastUser.begin(),
401 LUE = LastUser.end(); LUI != LUE; ++LUI) {
402 if (LUI->second == AP)
403 LastUser[LUI->first] = P;
408 /// Collect passes whose last user is P
409 void PMTopLevelManager::collectLastUses(SmallVector<Pass *, 12> &LastUses,
411 for (std::map<Pass *, Pass *>::iterator LUI = LastUser.begin(),
412 LUE = LastUser.end(); LUI != LUE; ++LUI)
413 if (LUI->second == P)
414 LastUses.push_back(LUI->first);
417 /// Schedule pass P for execution. Make sure that passes required by
418 /// P are run before P is run. Update analysis info maintained by
419 /// the manager. Remove dead passes. This is a recursive function.
420 void PMTopLevelManager::schedulePass(Pass *P) {
422 // TODO : Allocate function manager for this pass, other wise required set
423 // may be inserted into previous function manager
425 // Give pass a chance to prepare the stage.
426 P->preparePassManager(activeStack);
428 AnalysisUsage AnUsage;
429 P->getAnalysisUsage(AnUsage);
430 const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
431 for (std::vector<AnalysisID>::const_iterator I = RequiredSet.begin(),
432 E = RequiredSet.end(); I != E; ++I) {
434 Pass *AnalysisPass = findAnalysisPass(*I);
436 AnalysisPass = (*I)->createPass();
437 // Schedule this analysis run first only if it is not a lower level
438 // analysis pass. Lower level analsyis passes are run on the fly.
439 if (P->getPotentialPassManagerType () >=
440 AnalysisPass->getPotentialPassManagerType())
441 schedulePass(AnalysisPass);
447 // Now all required passes are available.
451 /// Find the pass that implements Analysis AID. Search immutable
452 /// passes and all pass managers. If desired pass is not found
453 /// then return NULL.
454 Pass *PMTopLevelManager::findAnalysisPass(AnalysisID AID) {
457 // Check pass managers
458 for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(),
459 E = PassManagers.end(); P == NULL && I != E; ++I) {
460 PMDataManager *PMD = *I;
461 P = PMD->findAnalysisPass(AID, false);
464 // Check other pass managers
465 for (std::vector<PMDataManager *>::iterator I = IndirectPassManagers.begin(),
466 E = IndirectPassManagers.end(); P == NULL && I != E; ++I)
467 P = (*I)->findAnalysisPass(AID, false);
469 for (std::vector<ImmutablePass *>::iterator I = ImmutablePasses.begin(),
470 E = ImmutablePasses.end(); P == NULL && I != E; ++I) {
471 const PassInfo *PI = (*I)->getPassInfo();
475 // If Pass not found then check the interfaces implemented by Immutable Pass
477 const std::vector<const PassInfo*> &ImmPI =
478 PI->getInterfacesImplemented();
479 if (std::find(ImmPI.begin(), ImmPI.end(), AID) != ImmPI.end())
487 // Print passes managed by this top level manager.
488 void PMTopLevelManager::dumpPasses() const {
490 if (PassDebugging < Structure)
493 // Print out the immutable passes
494 for (unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) {
495 ImmutablePasses[i]->dumpPassStructure(0);
498 // Every class that derives from PMDataManager also derives from Pass
499 // (sometimes indirectly), but there's no inheritance relationship
500 // between PMDataManager and Pass, so we have to dynamic_cast to get
501 // from a PMDataManager* to a Pass*.
502 for (std::vector<PMDataManager *>::const_iterator I = PassManagers.begin(),
503 E = PassManagers.end(); I != E; ++I)
504 dynamic_cast<Pass *>(*I)->dumpPassStructure(1);
507 void PMTopLevelManager::dumpArguments() const {
509 if (PassDebugging < Arguments)
512 cerr << "Pass Arguments: ";
513 for (std::vector<PMDataManager *>::const_iterator I = PassManagers.begin(),
514 E = PassManagers.end(); I != E; ++I) {
515 PMDataManager *PMD = *I;
516 PMD->dumpPassArguments();
521 void PMTopLevelManager::initializeAllAnalysisInfo() {
523 for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(),
524 E = PassManagers.end(); I != E; ++I) {
525 PMDataManager *PMD = *I;
526 PMD->initializeAnalysisInfo();
529 // Initailize other pass managers
530 for (std::vector<PMDataManager *>::iterator I = IndirectPassManagers.begin(),
531 E = IndirectPassManagers.end(); I != E; ++I)
532 (*I)->initializeAnalysisInfo();
536 PMTopLevelManager::~PMTopLevelManager() {
537 for (std::vector<PMDataManager *>::iterator I = PassManagers.begin(),
538 E = PassManagers.end(); I != E; ++I)
541 for (std::vector<ImmutablePass *>::iterator
542 I = ImmutablePasses.begin(), E = ImmutablePasses.end(); I != E; ++I)
546 //===----------------------------------------------------------------------===//
547 // PMDataManager implementation
549 /// Augement AvailableAnalysis by adding analysis made available by pass P.
550 void PMDataManager::recordAvailableAnalysis(Pass *P) {
552 if (const PassInfo *PI = P->getPassInfo()) {
553 AvailableAnalysis[PI] = P;
555 //This pass is the current implementation of all of the interfaces it
556 //implements as well.
557 const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
558 for (unsigned i = 0, e = II.size(); i != e; ++i)
559 AvailableAnalysis[II[i]] = P;
563 // Return true if P preserves high level analysis used by other
564 // passes managed by this manager
565 bool PMDataManager::preserveHigherLevelAnalysis(Pass *P) {
567 AnalysisUsage AnUsage;
568 P->getAnalysisUsage(AnUsage);
570 if (AnUsage.getPreservesAll())
573 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
574 for (std::vector<Pass *>::iterator I = HigherLevelAnalysis.begin(),
575 E = HigherLevelAnalysis.end(); I != E; ++I) {
577 if (!dynamic_cast<ImmutablePass*>(P1) &&
578 std::find(PreservedSet.begin(), PreservedSet.end(),
579 P1->getPassInfo()) ==
587 /// verifyPreservedAnalysis -- Verify analysis presreved by pass P.
588 void PMDataManager::verifyPreservedAnalysis(Pass *P) {
589 AnalysisUsage AnUsage;
590 P->getAnalysisUsage(AnUsage);
591 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
593 // Verify preserved analysis
594 for (std::vector<AnalysisID>::const_iterator I = PreservedSet.begin(),
595 E = PreservedSet.end(); I != E; ++I) {
597 Pass *AP = findAnalysisPass(AID, true);
599 AP->verifyAnalysis();
603 /// Remove Analyss not preserved by Pass P
604 void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
605 AnalysisUsage AnUsage;
606 P->getAnalysisUsage(AnUsage);
607 if (AnUsage.getPreservesAll())
610 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
611 for (std::map<AnalysisID, Pass*>::iterator I = AvailableAnalysis.begin(),
612 E = AvailableAnalysis.end(); I != E; ) {
613 std::map<AnalysisID, Pass*>::iterator Info = I++;
614 if (!dynamic_cast<ImmutablePass*>(Info->second)
615 && std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) ==
617 // Remove this analysis
618 AvailableAnalysis.erase(Info);
621 // Check inherited analysis also. If P is not preserving analysis
622 // provided by parent manager then remove it here.
623 for (unsigned Index = 0; Index < PMT_Last; ++Index) {
625 if (!InheritedAnalysis[Index])
628 for (std::map<AnalysisID, Pass*>::iterator
629 I = InheritedAnalysis[Index]->begin(),
630 E = InheritedAnalysis[Index]->end(); I != E; ) {
631 std::map<AnalysisID, Pass *>::iterator Info = I++;
632 if (!dynamic_cast<ImmutablePass*>(Info->second) &&
633 std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) ==
635 // Remove this analysis
636 InheritedAnalysis[Index]->erase(Info);
642 /// Remove analysis passes that are not used any longer
643 void PMDataManager::removeDeadPasses(Pass *P, const char *Msg,
644 enum PassDebuggingString DBG_STR) {
646 SmallVector<Pass *, 12> DeadPasses;
648 // If this is a on the fly manager then it does not have TPM.
652 TPM->collectLastUses(DeadPasses, P);
654 for (SmallVector<Pass *, 12>::iterator I = DeadPasses.begin(),
655 E = DeadPasses.end(); I != E; ++I) {
657 dumpPassInfo(*I, FREEING_MSG, DBG_STR, Msg);
659 if (TheTimeInfo) TheTimeInfo->passStarted(*I);
660 (*I)->releaseMemory();
661 if (TheTimeInfo) TheTimeInfo->passEnded(*I);
663 std::map<AnalysisID, Pass*>::iterator Pos =
664 AvailableAnalysis.find((*I)->getPassInfo());
666 // It is possible that pass is already removed from the AvailableAnalysis
667 if (Pos != AvailableAnalysis.end())
668 AvailableAnalysis.erase(Pos);
672 /// Add pass P into the PassVector. Update
673 /// AvailableAnalysis appropriately if ProcessAnalysis is true.
674 void PMDataManager::add(Pass *P,
675 bool ProcessAnalysis) {
677 // This manager is going to manage pass P. Set up analysis resolver
679 AnalysisResolver *AR = new AnalysisResolver(*this);
682 // If a FunctionPass F is the last user of ModulePass info M
683 // then the F's manager, not F, records itself as a last user of M.
684 SmallVector<Pass *, 12> TransferLastUses;
686 if (ProcessAnalysis) {
688 // At the moment, this pass is the last user of all required passes.
689 SmallVector<Pass *, 12> LastUses;
690 SmallVector<Pass *, 8> RequiredPasses;
691 SmallVector<AnalysisID, 8> ReqAnalysisNotAvailable;
693 unsigned PDepth = this->getDepth();
695 collectRequiredAnalysis(RequiredPasses,
696 ReqAnalysisNotAvailable, P);
697 for (SmallVector<Pass *, 8>::iterator I = RequiredPasses.begin(),
698 E = RequiredPasses.end(); I != E; ++I) {
699 Pass *PRequired = *I;
702 PMDataManager &DM = PRequired->getResolver()->getPMDataManager();
703 RDepth = DM.getDepth();
705 if (PDepth == RDepth)
706 LastUses.push_back(PRequired);
707 else if (PDepth > RDepth) {
708 // Let the parent claim responsibility of last use
709 TransferLastUses.push_back(PRequired);
710 // Keep track of higher level analysis used by this manager.
711 HigherLevelAnalysis.push_back(PRequired);
713 assert (0 && "Unable to accomodate Required Pass");
716 // Set P as P's last user until someone starts using P.
717 // However, if P is a Pass Manager then it does not need
718 // to record its last user.
719 if (!dynamic_cast<PMDataManager *>(P))
720 LastUses.push_back(P);
721 TPM->setLastUser(LastUses, P);
723 if (!TransferLastUses.empty()) {
724 Pass *My_PM = dynamic_cast<Pass *>(this);
725 TPM->setLastUser(TransferLastUses, My_PM);
726 TransferLastUses.clear();
729 // Now, take care of required analysises that are not available.
730 for (SmallVector<AnalysisID, 8>::iterator
731 I = ReqAnalysisNotAvailable.begin(),
732 E = ReqAnalysisNotAvailable.end() ;I != E; ++I) {
733 Pass *AnalysisPass = (*I)->createPass();
734 this->addLowerLevelRequiredPass(P, AnalysisPass);
737 // Take a note of analysis required and made available by this pass.
738 // Remove the analysis not preserved by this pass
739 removeNotPreservedAnalysis(P);
740 recordAvailableAnalysis(P);
744 PassVector.push_back(P);
748 /// Populate RP with analysis pass that are required by
749 /// pass P and are available. Populate RP_NotAvail with analysis
750 /// pass that are required by pass P but are not available.
751 void PMDataManager::collectRequiredAnalysis(SmallVector<Pass *, 8>&RP,
752 SmallVector<AnalysisID, 8> &RP_NotAvail,
754 AnalysisUsage AnUsage;
755 P->getAnalysisUsage(AnUsage);
756 const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
757 for (std::vector<AnalysisID>::const_iterator
758 I = RequiredSet.begin(), E = RequiredSet.end();
761 if (Pass *AnalysisPass = findAnalysisPass(*I, true))
762 RP.push_back(AnalysisPass);
764 RP_NotAvail.push_back(AID);
767 const std::vector<AnalysisID> &IDs = AnUsage.getRequiredTransitiveSet();
768 for (std::vector<AnalysisID>::const_iterator I = IDs.begin(),
769 E = IDs.end(); I != E; ++I) {
771 if (Pass *AnalysisPass = findAnalysisPass(*I, true))
772 RP.push_back(AnalysisPass);
774 RP_NotAvail.push_back(AID);
778 // All Required analyses should be available to the pass as it runs! Here
779 // we fill in the AnalysisImpls member of the pass so that it can
780 // successfully use the getAnalysis() method to retrieve the
781 // implementations it needs.
783 void PMDataManager::initializeAnalysisImpl(Pass *P) {
784 AnalysisUsage AnUsage;
785 P->getAnalysisUsage(AnUsage);
787 for (std::vector<const PassInfo *>::const_iterator
788 I = AnUsage.getRequiredSet().begin(),
789 E = AnUsage.getRequiredSet().end(); I != E; ++I) {
790 Pass *Impl = findAnalysisPass(*I, true);
792 // This may be analysis pass that is initialized on the fly.
793 // If that is not the case then it will raise an assert when it is used.
795 AnalysisResolver *AR = P->getResolver();
796 AR->addAnalysisImplsPair(*I, Impl);
800 /// Find the pass that implements Analysis AID. If desired pass is not found
801 /// then return NULL.
802 Pass *PMDataManager::findAnalysisPass(AnalysisID AID, bool SearchParent) {
804 // Check if AvailableAnalysis map has one entry.
805 std::map<AnalysisID, Pass*>::const_iterator I = AvailableAnalysis.find(AID);
807 if (I != AvailableAnalysis.end())
810 // Search Parents through TopLevelManager
812 return TPM->findAnalysisPass(AID);
817 // Print list of passes that are last used by P.
818 void PMDataManager::dumpLastUses(Pass *P, unsigned Offset) const{
820 SmallVector<Pass *, 12> LUses;
822 // If this is a on the fly manager then it does not have TPM.
826 TPM->collectLastUses(LUses, P);
828 for (SmallVector<Pass *, 12>::iterator I = LUses.begin(),
829 E = LUses.end(); I != E; ++I) {
830 llvm::cerr << "--" << std::string(Offset*2, ' ');
831 (*I)->dumpPassStructure(0);
835 void PMDataManager::dumpPassArguments() const {
836 for(std::vector<Pass *>::const_iterator I = PassVector.begin(),
837 E = PassVector.end(); I != E; ++I) {
838 if (PMDataManager *PMD = dynamic_cast<PMDataManager *>(*I))
839 PMD->dumpPassArguments();
841 if (const PassInfo *PI = (*I)->getPassInfo())
842 if (!PI->isAnalysisGroup())
843 cerr << " -" << PI->getPassArgument();
847 void PMDataManager::dumpPassInfo(Pass *P, enum PassDebuggingString S1,
848 enum PassDebuggingString S2,
850 if (PassDebugging < Executions)
852 cerr << (void*)this << std::string(getDepth()*2+1, ' ');
855 cerr << "Executing Pass '" << P->getPassName();
857 case MODIFICATION_MSG:
858 cerr << "Made Modification '" << P->getPassName();
861 cerr << " Freeing Pass '" << P->getPassName();
867 case ON_BASICBLOCK_MSG:
868 cerr << "' on BasicBlock '" << Msg << "'...\n";
870 case ON_FUNCTION_MSG:
871 cerr << "' on Function '" << Msg << "'...\n";
874 cerr << "' on Module '" << Msg << "'...\n";
877 cerr << "' on Loop " << Msg << "'...\n";
880 cerr << "' on Call Graph " << Msg << "'...\n";
887 void PMDataManager::dumpAnalysisSetInfo(const char *Msg, Pass *P,
888 const std::vector<AnalysisID> &Set)
890 if (PassDebugging >= Details && !Set.empty()) {
891 cerr << (void*)P << std::string(getDepth()*2+3, ' ') << Msg << " Analyses:";
892 for (unsigned i = 0; i != Set.size(); ++i) {
894 cerr << " " << Set[i]->getPassName();
900 /// Add RequiredPass into list of lower level passes required by pass P.
901 /// RequiredPass is run on the fly by Pass Manager when P requests it
902 /// through getAnalysis interface.
903 /// This should be handled by specific pass manager.
904 void PMDataManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {
906 TPM->dumpArguments();
910 // Module Level pass may required Function Level analysis info
911 // (e.g. dominator info). Pass manager uses on the fly function pass manager
912 // to provide this on demand. In that case, in Pass manager terminology,
913 // module level pass is requiring lower level analysis info managed by
914 // lower level pass manager.
916 // When Pass manager is not able to order required analysis info, Pass manager
917 // checks whether any lower level manager will be able to provide this
918 // analysis info on demand or not.
919 assert (0 && "Unable to handle Pass that requires lower level Analysis pass");
923 PMDataManager::~PMDataManager() {
925 for (std::vector<Pass *>::iterator I = PassVector.begin(),
926 E = PassVector.end(); I != E; ++I)
931 //===----------------------------------------------------------------------===//
932 // NOTE: Is this the right place to define this method ?
933 // getAnalysisToUpdate - Return an analysis result or null if it doesn't exist
934 Pass *AnalysisResolver::getAnalysisToUpdate(AnalysisID ID, bool dir) const {
935 return PM.findAnalysisPass(ID, dir);
938 Pass *AnalysisResolver::findImplPass(Pass *P, const PassInfo *AnalysisPI,
940 return PM.getOnTheFlyPass(P, AnalysisPI, F);
943 //===----------------------------------------------------------------------===//
944 // BBPassManager implementation
946 /// Execute all of the passes scheduled for execution by invoking
947 /// runOnBasicBlock method. Keep track of whether any of the passes modifies
948 /// the function, and if so, return true.
950 BBPassManager::runOnFunction(Function &F) {
952 if (F.isDeclaration())
955 bool Changed = doInitialization(F);
957 for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
958 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
959 BasicBlockPass *BP = getContainedPass(Index);
960 AnalysisUsage AnUsage;
961 BP->getAnalysisUsage(AnUsage);
963 dumpPassInfo(BP, EXECUTION_MSG, ON_BASICBLOCK_MSG, I->getNameStart());
964 dumpAnalysisSetInfo("Required", BP, AnUsage.getRequiredSet());
966 initializeAnalysisImpl(BP);
968 if (TheTimeInfo) TheTimeInfo->passStarted(BP);
969 Changed |= BP->runOnBasicBlock(*I);
970 if (TheTimeInfo) TheTimeInfo->passEnded(BP);
973 dumpPassInfo(BP, MODIFICATION_MSG, ON_BASICBLOCK_MSG,
975 dumpAnalysisSetInfo("Preserved", BP, AnUsage.getPreservedSet());
977 verifyPreservedAnalysis(BP);
978 removeNotPreservedAnalysis(BP);
979 recordAvailableAnalysis(BP);
980 removeDeadPasses(BP, I->getNameStart(), ON_BASICBLOCK_MSG);
983 return Changed |= doFinalization(F);
986 // Implement doInitialization and doFinalization
987 inline bool BBPassManager::doInitialization(Module &M) {
988 bool Changed = false;
990 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
991 BasicBlockPass *BP = getContainedPass(Index);
992 Changed |= BP->doInitialization(M);
998 inline bool BBPassManager::doFinalization(Module &M) {
999 bool Changed = false;
1001 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1002 BasicBlockPass *BP = getContainedPass(Index);
1003 Changed |= BP->doFinalization(M);
1009 inline bool BBPassManager::doInitialization(Function &F) {
1010 bool Changed = false;
1012 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1013 BasicBlockPass *BP = getContainedPass(Index);
1014 Changed |= BP->doInitialization(F);
1020 inline bool BBPassManager::doFinalization(Function &F) {
1021 bool Changed = false;
1023 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1024 BasicBlockPass *BP = getContainedPass(Index);
1025 Changed |= BP->doFinalization(F);
1032 //===----------------------------------------------------------------------===//
1033 // FunctionPassManager implementation
1035 /// Create new Function pass manager
1036 FunctionPassManager::FunctionPassManager(ModuleProvider *P) {
1037 FPM = new FunctionPassManagerImpl(0);
1038 // FPM is the top level manager.
1039 FPM->setTopLevelManager(FPM);
1041 AnalysisResolver *AR = new AnalysisResolver(*FPM);
1042 FPM->setResolver(AR);
1047 FunctionPassManager::~FunctionPassManager() {
1051 /// add - Add a pass to the queue of passes to run. This passes
1052 /// ownership of the Pass to the PassManager. When the
1053 /// PassManager_X is destroyed, the pass will be destroyed as well, so
1054 /// there is no need to delete the pass. (TODO delete passes.)
1055 /// This implies that all passes MUST be allocated with 'new'.
1056 void FunctionPassManager::add(Pass *P) {
1060 /// run - Execute all of the passes scheduled for execution. Keep
1061 /// track of whether any of the passes modifies the function, and if
1062 /// so, return true.
1064 bool FunctionPassManager::run(Function &F) {
1066 if (MP->materializeFunction(&F, &errstr)) {
1067 cerr << "Error reading bitcode file: " << errstr << "\n";
1074 /// doInitialization - Run all of the initializers for the function passes.
1076 bool FunctionPassManager::doInitialization() {
1077 return FPM->doInitialization(*MP->getModule());
1080 /// doFinalization - Run all of the finalizers for the function passes.
1082 bool FunctionPassManager::doFinalization() {
1083 return FPM->doFinalization(*MP->getModule());
1086 //===----------------------------------------------------------------------===//
1087 // FunctionPassManagerImpl implementation
1089 inline bool FunctionPassManagerImpl::doInitialization(Module &M) {
1090 bool Changed = false;
1092 for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {
1093 FPPassManager *FP = getContainedManager(Index);
1094 Changed |= FP->doInitialization(M);
1100 inline bool FunctionPassManagerImpl::doFinalization(Module &M) {
1101 bool Changed = false;
1103 for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {
1104 FPPassManager *FP = getContainedManager(Index);
1105 Changed |= FP->doFinalization(M);
1111 // Execute all the passes managed by this top level manager.
1112 // Return true if any function is modified by a pass.
1113 bool FunctionPassManagerImpl::run(Function &F) {
1115 bool Changed = false;
1117 TimingInfo::createTheTimeInfo();
1122 initializeAllAnalysisInfo();
1123 for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {
1124 FPPassManager *FP = getContainedManager(Index);
1125 Changed |= FP->runOnFunction(F);
1130 //===----------------------------------------------------------------------===//
1131 // FPPassManager implementation
1133 char FPPassManager::ID = 0;
1134 /// Print passes managed by this manager
1135 void FPPassManager::dumpPassStructure(unsigned Offset) {
1136 llvm::cerr << std::string(Offset*2, ' ') << "FunctionPass Manager\n";
1137 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1138 FunctionPass *FP = getContainedPass(Index);
1139 FP->dumpPassStructure(Offset + 1);
1140 dumpLastUses(FP, Offset+1);
1145 /// Execute all of the passes scheduled for execution by invoking
1146 /// runOnFunction method. Keep track of whether any of the passes modifies
1147 /// the function, and if so, return true.
1148 bool FPPassManager::runOnFunction(Function &F) {
1150 bool Changed = false;
1152 if (F.isDeclaration())
1155 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1156 FunctionPass *FP = getContainedPass(Index);
1158 AnalysisUsage AnUsage;
1159 FP->getAnalysisUsage(AnUsage);
1161 dumpPassInfo(FP, EXECUTION_MSG, ON_FUNCTION_MSG, F.getNameStart());
1162 dumpAnalysisSetInfo("Required", FP, AnUsage.getRequiredSet());
1164 initializeAnalysisImpl(FP);
1166 if (TheTimeInfo) TheTimeInfo->passStarted(FP);
1167 Changed |= FP->runOnFunction(F);
1168 if (TheTimeInfo) TheTimeInfo->passEnded(FP);
1171 dumpPassInfo(FP, MODIFICATION_MSG, ON_FUNCTION_MSG, F.getNameStart());
1172 dumpAnalysisSetInfo("Preserved", FP, AnUsage.getPreservedSet());
1174 verifyPreservedAnalysis(FP);
1175 removeNotPreservedAnalysis(FP);
1176 recordAvailableAnalysis(FP);
1177 removeDeadPasses(FP, F.getNameStart(), ON_FUNCTION_MSG);
1182 bool FPPassManager::runOnModule(Module &M) {
1184 bool Changed = doInitialization(M);
1186 for(Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
1187 this->runOnFunction(*I);
1189 return Changed |= doFinalization(M);
1192 inline bool FPPassManager::doInitialization(Module &M) {
1193 bool Changed = false;
1195 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1196 FunctionPass *FP = getContainedPass(Index);
1197 Changed |= FP->doInitialization(M);
1203 inline bool FPPassManager::doFinalization(Module &M) {
1204 bool Changed = false;
1206 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1207 FunctionPass *FP = getContainedPass(Index);
1208 Changed |= FP->doFinalization(M);
1214 //===----------------------------------------------------------------------===//
1215 // MPPassManager implementation
1217 /// Execute all of the passes scheduled for execution by invoking
1218 /// runOnModule method. Keep track of whether any of the passes modifies
1219 /// the module, and if so, return true.
1221 MPPassManager::runOnModule(Module &M) {
1222 bool Changed = false;
1224 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
1225 ModulePass *MP = getContainedPass(Index);
1227 AnalysisUsage AnUsage;
1228 MP->getAnalysisUsage(AnUsage);
1230 dumpPassInfo(MP, EXECUTION_MSG, ON_MODULE_MSG,
1231 M.getModuleIdentifier().c_str());
1232 dumpAnalysisSetInfo("Required", MP, AnUsage.getRequiredSet());
1234 initializeAnalysisImpl(MP);
1236 if (TheTimeInfo) TheTimeInfo->passStarted(MP);
1237 Changed |= MP->runOnModule(M);
1238 if (TheTimeInfo) TheTimeInfo->passEnded(MP);
1241 dumpPassInfo(MP, MODIFICATION_MSG, ON_MODULE_MSG,
1242 M.getModuleIdentifier().c_str());
1243 dumpAnalysisSetInfo("Preserved", MP, AnUsage.getPreservedSet());
1245 verifyPreservedAnalysis(MP);
1246 removeNotPreservedAnalysis(MP);
1247 recordAvailableAnalysis(MP);
1248 removeDeadPasses(MP, M.getModuleIdentifier().c_str(), ON_MODULE_MSG);
1253 /// Add RequiredPass into list of lower level passes required by pass P.
1254 /// RequiredPass is run on the fly by Pass Manager when P requests it
1255 /// through getAnalysis interface.
1256 void MPPassManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {
1258 assert (P->getPotentialPassManagerType() == PMT_ModulePassManager
1259 && "Unable to handle Pass that requires lower level Analysis pass");
1260 assert ((P->getPotentialPassManagerType() <
1261 RequiredPass->getPotentialPassManagerType())
1262 && "Unable to handle Pass that requires lower level Analysis pass");
1264 FunctionPassManagerImpl *FPP = OnTheFlyManagers[P];
1266 FPP = new FunctionPassManagerImpl(0);
1267 // FPP is the top level manager.
1268 FPP->setTopLevelManager(FPP);
1270 OnTheFlyManagers[P] = FPP;
1272 FPP->add(RequiredPass);
1274 // Register P as the last user of RequiredPass.
1275 SmallVector<Pass *, 12> LU;
1276 LU.push_back(RequiredPass);
1277 FPP->setLastUser(LU, P);
1280 /// Return function pass corresponding to PassInfo PI, that is
1281 /// required by module pass MP. Instantiate analysis pass, by using
1282 /// its runOnFunction() for function F.
1283 Pass* MPPassManager::getOnTheFlyPass(Pass *MP, const PassInfo *PI,
1285 AnalysisID AID = PI;
1286 FunctionPassManagerImpl *FPP = OnTheFlyManagers[MP];
1287 assert (FPP && "Unable to find on the fly pass");
1290 return (dynamic_cast<PMTopLevelManager *>(FPP))->findAnalysisPass(AID);
1294 //===----------------------------------------------------------------------===//
1295 // PassManagerImpl implementation
1297 /// run - Execute all of the passes scheduled for execution. Keep track of
1298 /// whether any of the passes modifies the module, and if so, return true.
1299 bool PassManagerImpl::run(Module &M) {
1301 bool Changed = false;
1303 TimingInfo::createTheTimeInfo();
1308 initializeAllAnalysisInfo();
1309 for (unsigned Index = 0; Index < getNumContainedManagers(); ++Index) {
1310 MPPassManager *MP = getContainedManager(Index);
1311 Changed |= MP->runOnModule(M);
1316 //===----------------------------------------------------------------------===//
1317 // PassManager implementation
1319 /// Create new pass manager
1320 PassManager::PassManager() {
1321 PM = new PassManagerImpl(0);
1322 // PM is the top level manager
1323 PM->setTopLevelManager(PM);
1326 PassManager::~PassManager() {
1330 /// add - Add a pass to the queue of passes to run. This passes ownership of
1331 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
1332 /// will be destroyed as well, so there is no need to delete the pass. This
1333 /// implies that all passes MUST be allocated with 'new'.
1335 PassManager::add(Pass *P) {
1339 /// run - Execute all of the passes scheduled for execution. Keep track of
1340 /// whether any of the passes modifies the module, and if so, return true.
1342 PassManager::run(Module &M) {
1346 //===----------------------------------------------------------------------===//
1347 // TimingInfo Class - This class is used to calculate information about the
1348 // amount of time each pass takes to execute. This only happens with
1349 // -time-passes is enabled on the command line.
1351 bool llvm::TimePassesIsEnabled = false;
1352 static cl::opt<bool,true>
1353 EnableTiming("time-passes", cl::location(TimePassesIsEnabled),
1354 cl::desc("Time each pass, printing elapsed time for each on exit"));
1356 // createTheTimeInfo - This method either initializes the TheTimeInfo pointer to
1357 // a non null value (if the -time-passes option is enabled) or it leaves it
1358 // null. It may be called multiple times.
1359 void TimingInfo::createTheTimeInfo() {
1360 if (!TimePassesIsEnabled || TheTimeInfo) return;
1362 // Constructed the first time this is called, iff -time-passes is enabled.
1363 // This guarantees that the object will be constructed before static globals,
1364 // thus it will be destroyed before them.
1365 static ManagedStatic<TimingInfo> TTI;
1366 TheTimeInfo = &*TTI;
1369 /// If TimingInfo is enabled then start pass timer.
1370 void StartPassTimer(Pass *P) {
1372 TheTimeInfo->passStarted(P);
1375 /// If TimingInfo is enabled then stop pass timer.
1376 void StopPassTimer(Pass *P) {
1378 TheTimeInfo->passEnded(P);
1381 //===----------------------------------------------------------------------===//
1382 // PMStack implementation
1385 // Pop Pass Manager from the stack and clear its analysis info.
1386 void PMStack::pop() {
1388 PMDataManager *Top = this->top();
1389 Top->initializeAnalysisInfo();
1394 // Push PM on the stack and set its top level manager.
1395 void PMStack::push(PMDataManager *PM) {
1397 PMDataManager *Top = NULL;
1398 assert (PM && "Unable to push. Pass Manager expected");
1400 if (this->empty()) {
1405 PMTopLevelManager *TPM = Top->getTopLevelManager();
1407 assert (TPM && "Unable to find top level manager");
1408 TPM->addIndirectPassManager(PM);
1409 PM->setTopLevelManager(TPM);
1415 // Dump content of the pass manager stack.
1416 void PMStack::dump() {
1417 for(std::deque<PMDataManager *>::iterator I = S.begin(),
1418 E = S.end(); I != E; ++I) {
1419 Pass *P = dynamic_cast<Pass *>(*I);
1420 printf("%s ", P->getPassName());
1426 /// Find appropriate Module Pass Manager in the PM Stack and
1427 /// add self into that manager.
1428 void ModulePass::assignPassManager(PMStack &PMS,
1429 PassManagerType PreferredType) {
1431 // Find Module Pass Manager
1432 while(!PMS.empty()) {
1433 PassManagerType TopPMType = PMS.top()->getPassManagerType();
1434 if (TopPMType == PreferredType)
1435 break; // We found desired pass manager
1436 else if (TopPMType > PMT_ModulePassManager)
1437 PMS.pop(); // Pop children pass managers
1442 PMS.top()->add(this);
1445 /// Find appropriate Function Pass Manager or Call Graph Pass Manager
1446 /// in the PM Stack and add self into that manager.
1447 void FunctionPass::assignPassManager(PMStack &PMS,
1448 PassManagerType PreferredType) {
1450 // Find Module Pass Manager (TODO : Or Call Graph Pass Manager)
1451 while(!PMS.empty()) {
1452 if (PMS.top()->getPassManagerType() > PMT_FunctionPassManager)
1457 FPPassManager *FPP = dynamic_cast<FPPassManager *>(PMS.top());
1459 // Create new Function Pass Manager
1461 assert(!PMS.empty() && "Unable to create Function Pass Manager");
1462 PMDataManager *PMD = PMS.top();
1464 // [1] Create new Function Pass Manager
1465 FPP = new FPPassManager(PMD->getDepth() + 1);
1467 // [2] Set up new manager's top level manager
1468 PMTopLevelManager *TPM = PMD->getTopLevelManager();
1469 TPM->addIndirectPassManager(FPP);
1471 // [3] Assign manager to manage this new manager. This may create
1472 // and push new managers into PMS
1474 // If Call Graph Pass Manager is active then use it to manage
1475 // this new Function Pass manager.
1476 if (PMD->getPassManagerType() == PMT_CallGraphPassManager)
1477 FPP->assignPassManager(PMS, PMT_CallGraphPassManager);
1479 FPP->assignPassManager(PMS);
1481 // [4] Push new manager into PMS
1485 // Assign FPP as the manager of this pass.
1489 /// Find appropriate Basic Pass Manager or Call Graph Pass Manager
1490 /// in the PM Stack and add self into that manager.
1491 void BasicBlockPass::assignPassManager(PMStack &PMS,
1492 PassManagerType PreferredType) {
1494 BBPassManager *BBP = NULL;
1496 // Basic Pass Manager is a leaf pass manager. It does not handle
1497 // any other pass manager.
1499 BBP = dynamic_cast<BBPassManager *>(PMS.top());
1501 // If leaf manager is not Basic Block Pass manager then create new
1502 // basic Block Pass manager.
1505 assert(!PMS.empty() && "Unable to create BasicBlock Pass Manager");
1506 PMDataManager *PMD = PMS.top();
1508 // [1] Create new Basic Block Manager
1509 BBP = new BBPassManager(PMD->getDepth() + 1);
1511 // [2] Set up new manager's top level manager
1512 // Basic Block Pass Manager does not live by itself
1513 PMTopLevelManager *TPM = PMD->getTopLevelManager();
1514 TPM->addIndirectPassManager(BBP);
1516 // [3] Assign manager to manage this new manager. This may create
1517 // and push new managers into PMS
1518 BBP->assignPassManager(PMS);
1520 // [4] Push new manager into PMS
1524 // Assign BBP as the manager of this pass.
1528 PassManagerBase::~PassManagerBase() {}