1 //===- PassManagerT.h - Container for Passes ---------------------*- C++ -*--=//
3 // This file defines the PassManagerT class. This class is used to hold,
4 // maintain, and optimize execution of Pass's. The PassManager class ensures
5 // that analysis results are available before a pass runs, and that Pass's are
6 // destroyed when the PassManager is destroyed.
8 // The PassManagerT template is instantiated three times to do its job. The
9 // public PassManager class is a Pimpl around the PassManagerT<Module> interface
10 // to avoid having all of the PassManager clients being exposed to the
11 // implementation details herein.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_PASSMANAGER_T_H
16 #define LLVM_PASSMANAGER_T_H
18 #include "llvm/Pass.h"
19 #include "Support/CommandLine.h"
20 #include "Support/LeakDetector.h"
21 #include "Support/Timer.h"
26 //===----------------------------------------------------------------------===//
27 // Pass debugging information. Often it is useful to find out what pass is
28 // running when a crash occurs in a utility. When this library is compiled with
29 // debugging on, a command line option (--debug-pass) is enabled that causes the
30 // pass name to be printed before it executes.
33 // Different debug levels that can be enabled...
35 None, Arguments, Structure, Executions, Details
38 static cl::opt<enum PassDebugLevel>
39 PassDebugging("debug-pass", cl::Hidden,
40 cl::desc("Print PassManager debugging information"),
42 clEnumVal(None , "disable debug output"),
43 clEnumVal(Arguments , "print pass arguments to pass to 'opt'"),
44 clEnumVal(Structure , "print pass structure before run()"),
45 clEnumVal(Executions, "print pass name before it is executed"),
46 clEnumVal(Details , "print pass details when it is executed"),
49 //===----------------------------------------------------------------------===//
50 // PMDebug class - a set of debugging functions, that are not to be
51 // instantiated by the template.
54 static void PerformPassStartupStuff(Pass *P) {
55 // If debugging is enabled, print out argument information...
56 if (PassDebugging >= Arguments) {
57 std::cerr << "Pass Arguments: ";
58 PrintArgumentInformation(P);
61 // Print the pass execution structure
62 if (PassDebugging >= Structure)
63 P->dumpPassStructure();
67 static void PrintArgumentInformation(const Pass *P);
68 static void PrintPassInformation(unsigned,const char*,Pass *, Annotable *);
69 static void PrintAnalysisSetInfo(unsigned,const char*,Pass *P,
70 const std::vector<AnalysisID> &);
74 //===----------------------------------------------------------------------===//
75 // TimingInfo Class - This class is used to calculate information about the
76 // amount of time each pass takes to execute. This only happens when
77 // -time-passes is enabled on the command line.
81 std::map<Pass*, Timer> TimingData;
84 // Private ctor, must use 'create' member
85 TimingInfo() : TG("... Pass execution timing report ...") {}
87 // Create method. If Timing is enabled, this creates and returns a new timing
88 // object, otherwise it returns null.
90 static TimingInfo *create();
92 // TimingDtor - Print out information about timing information
94 // Delete all of the timers...
96 // TimerGroup is deleted next, printing the report.
99 void passStarted(Pass *P) {
100 if (dynamic_cast<AnalysisResolver*>(P)) return;
101 std::map<Pass*, Timer>::iterator I = TimingData.find(P);
102 if (I == TimingData.end())
103 I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first;
104 I->second.startTimer();
106 void passEnded(Pass *P) {
107 if (dynamic_cast<AnalysisResolver*>(P)) return;
108 std::map<Pass*, Timer>::iterator I = TimingData.find(P);
109 assert (I != TimingData.end() && "passStarted/passEnded not nested right!");
110 I->second.stopTimer();
114 //===----------------------------------------------------------------------===//
115 // Declare the PassManagerTraits which will be specialized...
117 template<class UnitType> class PassManagerTraits; // Do not define.
120 //===----------------------------------------------------------------------===//
121 // PassManagerT - Container object for passes. The PassManagerT destructor
122 // deletes all passes contained inside of the PassManagerT, so you shouldn't
123 // delete passes manually, and all passes should be dynamically allocated.
125 template<typename UnitType>
126 class PassManagerT : public PassManagerTraits<UnitType>,public AnalysisResolver{
127 typedef PassManagerTraits<UnitType> Traits;
128 typedef typename Traits::PassClass PassClass;
129 typedef typename Traits::SubPassClass SubPassClass;
130 typedef typename Traits::BatcherClass BatcherClass;
131 typedef typename Traits::ParentClass ParentClass;
133 friend typename Traits::PassClass;
134 friend typename Traits::SubPassClass;
136 friend class ImmutablePass;
138 std::vector<PassClass*> Passes; // List of passes to run
139 std::vector<ImmutablePass*> ImmutablePasses; // List of immutable passes
141 // The parent of this pass manager...
142 ParentClass * const Parent;
144 // The current batcher if one is in use, or null
145 BatcherClass *Batcher;
147 // CurrentAnalyses - As the passes are being run, this map contains the
148 // analyses that are available to the current pass for use. This is accessed
149 // through the getAnalysis() function in this class and in Pass.
151 std::map<AnalysisID, Pass*> CurrentAnalyses;
153 // LastUseOf - This map keeps track of the last usage in our pipeline of a
154 // particular pass. When executing passes, the memory for .first is free'd
155 // after .second is run.
157 std::map<Pass*, Pass*> LastUseOf;
160 PassManagerT(ParentClass *Par = 0) : Parent(Par), Batcher(0) {}
162 // Delete all of the contained passes...
163 for (typename std::vector<PassClass*>::iterator
164 I = Passes.begin(), E = Passes.end(); I != E; ++I)
167 for (std::vector<ImmutablePass*>::iterator
168 I = ImmutablePasses.begin(), E = ImmutablePasses.end(); I != E; ++I)
172 // run - Run all of the queued passes on the specified module in an optimal
174 virtual bool runOnUnit(UnitType *M) {
175 bool MadeChanges = false;
177 CurrentAnalyses.clear();
179 // Add any immutable passes to the CurrentAnalyses set...
180 for (unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) {
181 ImmutablePass *IPass = ImmutablePasses[i];
182 if (const PassInfo *PI = IPass->getPassInfo()) {
183 CurrentAnalyses[PI] = IPass;
185 const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
186 for (unsigned i = 0, e = II.size(); i != e; ++i)
187 CurrentAnalyses[II[i]] = IPass;
191 // LastUserOf - This contains the inverted LastUseOfMap...
192 std::map<Pass *, std::vector<Pass*> > LastUserOf;
193 for (std::map<Pass*, Pass*>::iterator I = LastUseOf.begin(),
194 E = LastUseOf.end(); I != E; ++I)
195 LastUserOf[I->second].push_back(I->first);
198 // Output debug information...
199 if (Parent == 0) PMDebug::PerformPassStartupStuff(this);
201 // Run all of the passes
202 for (unsigned i = 0, e = Passes.size(); i < e; ++i) {
203 PassClass *P = Passes[i];
205 PMDebug::PrintPassInformation(getDepth(), "Executing Pass", P,
208 // Get information about what analyses the pass uses...
209 AnalysisUsage AnUsage;
210 P->getAnalysisUsage(AnUsage);
211 PMDebug::PrintAnalysisSetInfo(getDepth(), "Required", P,
212 AnUsage.getRequiredSet());
214 // All Required analyses should be available to the pass as it runs! Here
215 // we fill in the AnalysisImpls member of the pass so that it can
216 // successfully use the getAnalysis() method to retrieve the
217 // implementations it needs.
219 P->AnalysisImpls.clear();
220 P->AnalysisImpls.reserve(AnUsage.getRequiredSet().size());
221 for (std::vector<const PassInfo *>::const_iterator
222 I = AnUsage.getRequiredSet().begin(),
223 E = AnUsage.getRequiredSet().end(); I != E; ++I) {
224 Pass *Impl = getAnalysisOrNullUp(*I);
226 std::cerr << "Analysis '" << (*I)->getPassName()
227 << "' used but not available!";
228 assert(0 && "Analysis used but not available!");
229 } else if (PassDebugging == Details) {
230 if ((*I)->getPassName() != std::string(Impl->getPassName()))
231 std::cerr << " Interface '" << (*I)->getPassName()
232 << "' implemented by '" << Impl->getPassName() << "'\n";
234 P->AnalysisImpls.push_back(std::make_pair(*I, Impl));
239 bool Changed = runPass(P, M);
241 MadeChanges |= Changed;
243 // Check for memory leaks by the pass...
244 LeakDetector::checkForGarbage(std::string("after running pass '") +
245 P->getPassName() + "'");
248 PMDebug::PrintPassInformation(getDepth()+1, "Made Modification", P,
250 PMDebug::PrintAnalysisSetInfo(getDepth(), "Preserved", P,
251 AnUsage.getPreservedSet());
254 // Erase all analyses not in the preserved set...
255 if (!AnUsage.getPreservesAll()) {
256 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
257 for (std::map<AnalysisID, Pass*>::iterator I = CurrentAnalyses.begin(),
258 E = CurrentAnalyses.end(); I != E; )
259 if (std::find(PreservedSet.begin(), PreservedSet.end(), I->first) !=
261 ++I; // This analysis is preserved, leave it in the available set...
263 if (!dynamic_cast<ImmutablePass*>(I->second)) {
264 #if MAP_DOESNT_HAVE_BROKEN_ERASE_MEMBER
265 I = CurrentAnalyses.erase(I); // Analysis not preserved!
267 // GCC 2.95.3 STL doesn't have correct erase member!
268 CurrentAnalyses.erase(I);
269 I = CurrentAnalyses.begin();
277 // Add the current pass to the set of passes that have been run, and are
278 // thus available to users.
280 if (const PassInfo *PI = P->getPassInfo()) {
281 CurrentAnalyses[PI] = P;
283 // This pass is the current implementation of all of the interfaces it
284 // implements as well.
286 const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
287 for (unsigned i = 0, e = II.size(); i != e; ++i)
288 CurrentAnalyses[II[i]] = P;
291 // Free memory for any passes that we are the last use of...
292 std::vector<Pass*> &DeadPass = LastUserOf[P];
293 for (std::vector<Pass*>::iterator I = DeadPass.begin(),E = DeadPass.end();
295 PMDebug::PrintPassInformation(getDepth()+1, "Freeing Pass", *I,
297 (*I)->releaseMemory();
300 // Make sure to remove dead passes from the CurrentAnalyses list...
301 for (std::map<AnalysisID, Pass*>::iterator I = CurrentAnalyses.begin();
302 I != CurrentAnalyses.end(); ) {
303 std::vector<Pass*>::iterator DPI = std::find(DeadPass.begin(),
304 DeadPass.end(), I->second);
305 if (DPI != DeadPass.end()) { // This pass is dead now... remove it
306 std::map<AnalysisID, Pass*>::iterator IDead = I++;
307 CurrentAnalyses.erase(IDead);
309 ++I; // Move on to the next element...
316 // dumpPassStructure - Implement the -debug-passes=PassStructure option
317 virtual void dumpPassStructure(unsigned Offset = 0) {
318 // Print out the immutable passes...
319 for (unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i)
320 ImmutablePasses[i]->dumpPassStructure(0);
322 std::cerr << std::string(Offset*2, ' ') << Traits::getPMName()
323 << " Pass Manager\n";
324 for (typename std::vector<PassClass*>::iterator
325 I = Passes.begin(), E = Passes.end(); I != E; ++I) {
327 P->dumpPassStructure(Offset+1);
329 // Loop through and see which classes are destroyed after this one...
330 for (std::map<Pass*, Pass*>::iterator I = LastUseOf.begin(),
331 E = LastUseOf.end(); I != E; ++I) {
332 if (P == I->second) {
333 std::cerr << "--" << std::string(Offset*2, ' ');
334 I->first->dumpPassStructure(0);
340 Pass *getAnalysisOrNullDown(const PassInfo *ID) const {
341 std::map<AnalysisID, Pass*>::const_iterator I = CurrentAnalyses.find(ID);
343 if (I != CurrentAnalyses.end())
344 return I->second; // Found it.
347 return ((AnalysisResolver*)Batcher)->getAnalysisOrNullDown(ID);
351 Pass *getAnalysisOrNullUp(const PassInfo *ID) const {
352 std::map<AnalysisID, Pass*>::const_iterator I = CurrentAnalyses.find(ID);
353 if (I != CurrentAnalyses.end())
354 return I->second; // Found it.
356 if (Parent) // Try scanning...
357 return Parent->getAnalysisOrNullUp(ID);
361 // {start/end}Pass - Called when a pass is started, it just propagates
362 // information up to the top level PassManagerT object to tell it that a pass
363 // has started or ended. This is used to gather timing information about
366 void startPass(Pass *P) {
367 if (Parent) Parent->startPass(P);
370 void endPass(Pass *P) {
371 if (Parent) Parent->endPass(P);
375 // markPassUsed - Inform higher level pass managers (and ourselves)
376 // that these analyses are being used by this pass. This is used to
377 // make sure that analyses are not free'd before we have to use
380 void markPassUsed(const PassInfo *P, Pass *User) {
381 std::map<AnalysisID, Pass*>::const_iterator I = CurrentAnalyses.find(P);
383 if (I != CurrentAnalyses.end()) {
384 LastUseOf[I->second] = User; // Local pass, extend the lifetime
386 // Pass not in current available set, must be a higher level pass
387 // available to us, propagate to parent pass manager... We tell the
388 // parent that we (the passmanager) are using the analysis so that it
389 // frees the analysis AFTER this pass manager runs.
392 Parent->markPassUsed(P, this);
394 assert(0 && "Pass available but not found! "
395 "Perhaps this is a module pass requiring a function pass?");
400 // Return the number of parent PassManagers that exist
401 virtual unsigned getDepth() const {
402 if (Parent == 0) return 0;
403 return 1 + Parent->getDepth();
406 virtual unsigned getNumContainedPasses() const { return Passes.size(); }
407 virtual const Pass *getContainedPass(unsigned N) const {
408 assert(N < Passes.size() && "Pass number out of range!");
412 // add - Add a pass to the queue of passes to run. This gives ownership of
413 // the Pass to the PassManager. When the PassManager is destroyed, the pass
414 // will be destroyed as well, so there is no need to delete the pass. This
415 // implies that all passes MUST be new'd.
417 void add(PassClass *P) {
418 // Get information about what analyses the pass uses...
419 AnalysisUsage AnUsage;
420 P->getAnalysisUsage(AnUsage);
421 const std::vector<AnalysisID> &Required = AnUsage.getRequiredSet();
423 // Loop over all of the analyses used by this pass,
424 for (std::vector<AnalysisID>::const_iterator I = Required.begin(),
425 E = Required.end(); I != E; ++I) {
426 if (getAnalysisOrNullDown(*I) == 0)
427 add((PassClass*)(*I)->createPass());
430 // Tell the pass to add itself to this PassManager... the way it does so
431 // depends on the class of the pass, and is critical to laying out passes in
432 // an optimal order..
434 P->addToPassManager(this, AnUsage);
439 // addPass - These functions are used to implement the subclass specific
440 // behaviors present in PassManager. Basically the add(Pass*) method ends up
441 // reflecting its behavior into a Pass::addToPassManager call. Subclasses of
442 // Pass override it specifically so that they can reflect the type
443 // information inherent in "this" back to the PassManager.
445 // For generic Pass subclasses (which are interprocedural passes), we simply
446 // add the pass to the end of the pass list and terminate any accumulation of
447 // FunctionPass's that are present.
449 void addPass(PassClass *P, AnalysisUsage &AnUsage) {
450 const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
452 // FIXME: If this pass being added isn't killed by any of the passes in the
453 // batcher class then we can reorder to pass to execute before the batcher
454 // does, which will potentially allow us to batch more passes!
456 //const std::vector<AnalysisID> &ProvidedSet = AnUsage.getProvidedSet();
457 if (Batcher /*&& ProvidedSet.empty()*/)
458 closeBatcher(); // This pass cannot be batched!
460 // Set the Resolver instance variable in the Pass so that it knows where to
461 // find this object...
463 setAnalysisResolver(P, this);
466 // Inform higher level pass managers (and ourselves) that these analyses are
467 // being used by this pass. This is used to make sure that analyses are not
468 // free'd before we have to use them...
470 for (std::vector<AnalysisID>::const_iterator I = RequiredSet.begin(),
471 E = RequiredSet.end(); I != E; ++I)
472 markPassUsed(*I, P); // Mark *I as used by P
474 // Erase all analyses not in the preserved set...
475 if (!AnUsage.getPreservesAll()) {
476 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
477 for (std::map<AnalysisID, Pass*>::iterator I = CurrentAnalyses.begin(),
478 E = CurrentAnalyses.end(); I != E; ) {
479 if (std::find(PreservedSet.begin(), PreservedSet.end(), I->first) ==
480 PreservedSet.end()) { // Analysis not preserved!
481 CurrentAnalyses.erase(I); // Remove from available analyses
482 I = CurrentAnalyses.begin();
489 // Add this pass to the currently available set...
490 if (const PassInfo *PI = P->getPassInfo()) {
491 CurrentAnalyses[PI] = P;
493 // This pass is the current implementation of all of the interfaces it
494 // implements as well.
496 const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
497 for (unsigned i = 0, e = II.size(); i != e; ++i)
498 CurrentAnalyses[II[i]] = P;
501 // For now assume that our results are never used...
505 // For FunctionPass subclasses, we must be sure to batch the FunctionPass's
506 // together in a BatcherClass object so that all of the analyses are run
507 // together a function at a time.
509 void addPass(SubPassClass *MP, AnalysisUsage &AnUsage) {
510 if (Batcher == 0) // If we don't have a batcher yet, make one now.
511 Batcher = new BatcherClass(this);
512 // The Batcher will queue the passes up
513 MP->addToPassManager(Batcher, AnUsage);
516 // closeBatcher - Terminate the batcher that is being worked on.
517 void closeBatcher() {
519 Passes.push_back(Batcher);
525 // When an ImmutablePass is added, it gets added to the top level pass
527 void addPass(ImmutablePass *IP, AnalysisUsage &AU) {
528 if (Parent) { // Make sure this request goes to the top level passmanager...
529 Parent->addPass(IP, AU);
533 // Set the Resolver instance variable in the Pass so that it knows where to
534 // find this object...
536 setAnalysisResolver(IP, this);
537 ImmutablePasses.push_back(IP);
539 // Add this pass to the currently available set...
540 if (const PassInfo *PI = IP->getPassInfo()) {
541 CurrentAnalyses[PI] = IP;
543 // This pass is the current implementation of all of the interfaces it
544 // implements as well.
546 const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
547 for (unsigned i = 0, e = II.size(); i != e; ++i)
548 CurrentAnalyses[II[i]] = IP;
555 //===----------------------------------------------------------------------===//
556 // PassManagerTraits<BasicBlock> Specialization
558 // This pass manager is used to group together all of the BasicBlockPass's
559 // into a single unit.
561 template<> struct PassManagerTraits<BasicBlock> : public BasicBlockPass {
562 // PassClass - The type of passes tracked by this PassManager
563 typedef BasicBlockPass PassClass;
565 // SubPassClass - The types of classes that should be collated together
566 // This is impossible to match, so BasicBlock instantiations of PassManagerT
569 typedef PassManagerT<Module> SubPassClass;
571 // BatcherClass - The type to use for collation of subtypes... This class is
572 // never instantiated for the PassManager<BasicBlock>, but it must be an
573 // instance of PassClass to typecheck.
575 typedef PassClass BatcherClass;
577 // ParentClass - The type of the parent PassManager...
578 typedef PassManagerT<Function> ParentClass;
580 // PMType - The type of the passmanager that subclasses this class
581 typedef PassManagerT<BasicBlock> PMType;
583 // runPass - Specify how the pass should be run on the UnitType
584 static bool runPass(PassClass *P, BasicBlock *M) {
585 // todo, init and finalize
586 return P->runOnBasicBlock(*M);
589 // Dummy implementation of PassStarted/PassEnded
590 static void PassStarted(Pass *P) {}
591 static void PassEnded(Pass *P) {}
593 // getPMName() - Return the name of the unit the PassManager operates on for
595 const char *getPMName() const { return "BasicBlock"; }
596 virtual const char *getPassName() const { return "BasicBlock Pass Manager"; }
598 // Implement the BasicBlockPass interface...
599 virtual bool doInitialization(Module &M);
600 virtual bool doInitialization(Function &F);
601 virtual bool runOnBasicBlock(BasicBlock &BB);
602 virtual bool doFinalization(Function &F);
603 virtual bool doFinalization(Module &M);
605 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
606 AU.setPreservesAll();
612 //===----------------------------------------------------------------------===//
613 // PassManagerTraits<Function> Specialization
615 // This pass manager is used to group together all of the FunctionPass's
616 // into a single unit.
618 template<> struct PassManagerTraits<Function> : public FunctionPass {
619 // PassClass - The type of passes tracked by this PassManager
620 typedef FunctionPass PassClass;
622 // SubPassClass - The types of classes that should be collated together
623 typedef BasicBlockPass SubPassClass;
625 // BatcherClass - The type to use for collation of subtypes...
626 typedef PassManagerT<BasicBlock> BatcherClass;
628 // ParentClass - The type of the parent PassManager...
629 typedef PassManagerT<Module> ParentClass;
631 // PMType - The type of the passmanager that subclasses this class
632 typedef PassManagerT<Function> PMType;
634 // runPass - Specify how the pass should be run on the UnitType
635 static bool runPass(PassClass *P, Function *F) {
636 return P->runOnFunction(*F);
639 // Dummy implementation of PassStarted/PassEnded
640 static void PassStarted(Pass *P) {}
641 static void PassEnded(Pass *P) {}
643 // getPMName() - Return the name of the unit the PassManager operates on for
645 const char *getPMName() const { return "Function"; }
646 virtual const char *getPassName() const { return "Function Pass Manager"; }
648 // Implement the FunctionPass interface...
649 virtual bool doInitialization(Module &M);
650 virtual bool runOnFunction(Function &F);
651 virtual bool doFinalization(Module &M);
653 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
654 AU.setPreservesAll();
660 //===----------------------------------------------------------------------===//
661 // PassManagerTraits<Module> Specialization
663 // This is the top level PassManager implementation that holds generic passes.
665 template<> struct PassManagerTraits<Module> : public Pass {
666 // PassClass - The type of passes tracked by this PassManager
667 typedef Pass PassClass;
669 // SubPassClass - The types of classes that should be collated together
670 typedef FunctionPass SubPassClass;
672 // BatcherClass - The type to use for collation of subtypes...
673 typedef PassManagerT<Function> BatcherClass;
675 // ParentClass - The type of the parent PassManager...
676 typedef AnalysisResolver ParentClass;
678 // runPass - Specify how the pass should be run on the UnitType
679 static bool runPass(PassClass *P, Module *M) { return P->run(*M); }
681 // getPMName() - Return the name of the unit the PassManager operates on for
683 const char *getPMName() const { return "Module"; }
684 virtual const char *getPassName() const { return "Module Pass Manager"; }
686 // TimingInformation - This data member maintains timing information for each
687 // of the passes that is executed.
689 TimingInfo *TimeInfo;
691 // PassStarted/Ended - This callback is notified any time a pass is started
692 // or stops. This is used to collect timing information about the different
693 // passes being executed.
695 void PassStarted(Pass *P) {
696 if (TimeInfo) TimeInfo->passStarted(P);
698 void PassEnded(Pass *P) {
699 if (TimeInfo) TimeInfo->passEnded(P);
702 // run - Implement the PassManager interface...
703 bool run(Module &M) {
704 TimeInfo = TimingInfo::create();
705 bool Result = ((PassManagerT<Module>*)this)->runOnUnit(&M);
713 // PassManagerTraits constructor - Create a timing info object if the user
714 // specified timing info should be collected on the command line.
716 PassManagerTraits() : TimeInfo(0) {}
721 //===----------------------------------------------------------------------===//
722 // PassManagerTraits Method Implementations
725 // PassManagerTraits<BasicBlock> Implementations
727 inline bool PassManagerTraits<BasicBlock>::doInitialization(Module &M) {
728 bool Changed = false;
729 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
730 ((PMType*)this)->Passes[i]->doInitialization(M);
734 inline bool PassManagerTraits<BasicBlock>::doInitialization(Function &F) {
735 bool Changed = false;
736 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
737 ((PMType*)this)->Passes[i]->doInitialization(F);
741 inline bool PassManagerTraits<BasicBlock>::runOnBasicBlock(BasicBlock &BB) {
742 return ((PMType*)this)->runOnUnit(&BB);
745 inline bool PassManagerTraits<BasicBlock>::doFinalization(Function &F) {
746 bool Changed = false;
747 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
748 ((PMType*)this)->Passes[i]->doFinalization(F);
752 inline bool PassManagerTraits<BasicBlock>::doFinalization(Module &M) {
753 bool Changed = false;
754 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
755 ((PMType*)this)->Passes[i]->doFinalization(M);
760 // PassManagerTraits<Function> Implementations
762 inline bool PassManagerTraits<Function>::doInitialization(Module &M) {
763 bool Changed = false;
764 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
765 ((PMType*)this)->Passes[i]->doInitialization(M);
769 inline bool PassManagerTraits<Function>::runOnFunction(Function &F) {
770 return ((PMType*)this)->runOnUnit(&F);
773 inline bool PassManagerTraits<Function>::doFinalization(Module &M) {
774 bool Changed = false;
775 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
776 ((PMType*)this)->Passes[i]->doFinalization(M);