blob: 599f4b08c9280ca47da3cf0ac1ee2a0d51358a9b [file] [log] [blame]
Devang Patel6e5a1132006-11-07 21:31:57 +00001//===- PassManager.cpp - LLVM Pass Infrastructure Implementation ----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Devang Patelca58e352006-11-08 10:05:38 +00005// This file was developed by Devang Patel and is distributed under
Devang Patel6e5a1132006-11-07 21:31:57 +00006// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the LLVM Pass Manager infrastructure.
11//
12//===----------------------------------------------------------------------===//
13
14
15#include "llvm/PassManager.h"
Devang Patel6e5a1132006-11-07 21:31:57 +000016#include "llvm/Module.h"
Devang Patela9844592006-11-11 01:31:05 +000017#include <vector>
18#include <set>
Devang Patel6e5a1132006-11-07 21:31:57 +000019
20using namespace llvm;
21
Devang Patelca58e352006-11-08 10:05:38 +000022namespace llvm {
23
Devang Patela9844592006-11-11 01:31:05 +000024/// CommonPassManagerImpl helps pass manager analysis required by
25/// the managed passes. It provides methods to add/remove analysis
26/// available and query if certain analysis is available or not.
27class CommonPassManagerImpl : public Pass {
28
29public:
30
31 /// Return true IFF pass P's required analysis set does not required new
32 /// manager.
33 bool manageablePass(Pass *P);
34
35 /// Return true IFF AnalysisID AID is currently available.
36 bool analysisCurrentlyAvailable(AnalysisID AID);
37
38 /// Augment RequiredAnalysis by adding analysis required by pass P.
39 void noteDownRequiredAnalysis(Pass *P);
40
41 /// Augment AvailableAnalysis by adding analysis made available by pass P.
42 void noteDownAvailableAnalysis(Pass *P);
43
44 /// Remove AnalysisID from the RequiredSet
45 void removeAnalysis(AnalysisID AID);
46
47 /// Remove Analysis that is not preserved by the pass
48 void removeNotPreservedAnalysis(Pass *P);
49
50 /// Remove dead passes
51 void removeDeadPasses() { /* TODO : Implement */ }
52
Devang Patel8cad70d2006-11-11 01:51:02 +000053 /// Add pass P into the PassVector. Update RequiredAnalysis and
54 /// AvailableAnalysis appropriately
55 void addPassToManager (Pass *P);
56
57 inline std::vector<Pass *>::iterator passVectorBegin() {
58 return PassVector.begin();
59 }
60
61 inline std::vector<Pass *>::iterator passVectorEnd() {
62 return PassVector.end();
63 }
64
Devang Patela9844592006-11-11 01:31:05 +000065private:
66 // Analysis required by the passes managed by this manager
67 std::vector<AnalysisID> RequiredAnalysis;
68
69 // set of available Analysis
70 std::set<AnalysisID> AvailableAnalysis;
Devang Patel8cad70d2006-11-11 01:51:02 +000071
72 // Collection of pass that are managed by this manager
73 std::vector<Pass *> PassVector;
Devang Patela9844592006-11-11 01:31:05 +000074};
75
Devang Patelca58e352006-11-08 10:05:38 +000076/// BasicBlockPassManager_New manages BasicBlockPass. It batches all the
77/// pass together and sequence them to process one basic block before
78/// processing next basic block.
Devang Patel0ed47792006-11-10 21:33:13 +000079class BasicBlockPassManager_New : public CommonPassManagerImpl {
Devang Patelca58e352006-11-08 10:05:38 +000080
81public:
82 BasicBlockPassManager_New() { }
83
84 /// Add a pass into a passmanager queue.
85 bool addPass(Pass *p);
86
87 /// Execute all of the passes scheduled for execution. Keep track of
88 /// whether any of the passes modifies the function, and if so, return true.
89 bool runOnFunction(Function &F);
90
91private:
Devang Patelca58e352006-11-08 10:05:38 +000092};
93
Devang Patel4e12f862006-11-08 10:44:40 +000094/// FunctionPassManagerImpl_New manages FunctionPasses and BasicBlockPassManagers.
Devang Patelca58e352006-11-08 10:05:38 +000095/// It batches all function passes and basic block pass managers together and
96/// sequence them to process one function at a time before processing next
97/// function.
Devang Patel0ed47792006-11-10 21:33:13 +000098class FunctionPassManagerImpl_New : public CommonPassManagerImpl {
Devang Patelca58e352006-11-08 10:05:38 +000099public:
Devang Patel4e12f862006-11-08 10:44:40 +0000100 FunctionPassManagerImpl_New(ModuleProvider *P) { /* TODO */ }
101 FunctionPassManagerImpl_New() {
Devang Patelca58e352006-11-08 10:05:38 +0000102 activeBBPassManager = NULL;
103 }
Devang Patel4e12f862006-11-08 10:44:40 +0000104 ~FunctionPassManagerImpl_New() { /* TODO */ };
Devang Patelca58e352006-11-08 10:05:38 +0000105
106 /// add - Add a pass to the queue of passes to run. This passes
107 /// ownership of the Pass to the PassManager. When the
108 /// PassManager_X is destroyed, the pass will be destroyed as well, so
109 /// there is no need to delete the pass. (TODO delete passes.)
110 /// This implies that all passes MUST be allocated with 'new'.
111 void add(Pass *P) { /* TODO*/ }
112
113 /// Add pass into the pass manager queue.
114 bool addPass(Pass *P);
115
116 /// Execute all of the passes scheduled for execution. Keep
117 /// track of whether any of the passes modifies the function, and if
118 /// so, return true.
119 bool runOnModule(Module &M);
120
121private:
Devang Patelca58e352006-11-08 10:05:38 +0000122 // Active Pass Managers
123 BasicBlockPassManager_New *activeBBPassManager;
124};
125
126/// ModulePassManager_New manages ModulePasses and function pass managers.
127/// It batches all Module passes passes and function pass managers together and
128/// sequence them to process one module.
Devang Patel0ed47792006-11-10 21:33:13 +0000129class ModulePassManager_New : public CommonPassManagerImpl {
Devang Patelca58e352006-11-08 10:05:38 +0000130
131public:
132 ModulePassManager_New() { activeFunctionPassManager = NULL; }
133
134 /// Add a pass into a passmanager queue.
135 bool addPass(Pass *p);
136
137 /// run - Execute all of the passes scheduled for execution. Keep track of
138 /// whether any of the passes modifies the module, and if so, return true.
139 bool runOnModule(Module &M);
140
141private:
Devang Patelca58e352006-11-08 10:05:38 +0000142 // Active Pass Manager
Devang Patel4e12f862006-11-08 10:44:40 +0000143 FunctionPassManagerImpl_New *activeFunctionPassManager;
Devang Patelca58e352006-11-08 10:05:38 +0000144};
145
Devang Patel376fefa2006-11-08 10:29:57 +0000146/// PassManager_New manages ModulePassManagers
Devang Patel0ed47792006-11-10 21:33:13 +0000147class PassManagerImpl_New : public CommonPassManagerImpl {
Devang Patel376fefa2006-11-08 10:29:57 +0000148
149public:
150
151 /// add - Add a pass to the queue of passes to run. This passes ownership of
152 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
153 /// will be destroyed as well, so there is no need to delete the pass. This
154 /// implies that all passes MUST be allocated with 'new'.
155 void add(Pass *P);
156
157 /// run - Execute all of the passes scheduled for execution. Keep track of
158 /// whether any of the passes modifies the module, and if so, return true.
159 bool run(Module &M);
160
161private:
162
163 /// Add a pass into a passmanager queue. This is used by schedulePasses
164 bool addPass(Pass *p);
165
166 /// Schedule all passes collected in pass queue using add(). Add all the
167 /// schedule passes into various manager's queue using addPass().
168 void schedulePasses();
169
170 // Collection of pass managers
171 std::vector<ModulePassManager_New *> PassManagers;
172
Devang Patel376fefa2006-11-08 10:29:57 +0000173 // Active Pass Manager
174 ModulePassManager_New *activeManager;
175};
176
Devang Patelca58e352006-11-08 10:05:38 +0000177} // End of llvm namespace
178
Devang Patel0ed47792006-11-10 21:33:13 +0000179// CommonPassManagerImpl implementation
Devang Patelf68a3492006-11-07 22:35:17 +0000180
Devang Pateld65e9e92006-11-08 01:31:28 +0000181/// Return true IFF pass P's required analysis set does not required new
Devang Patelf68a3492006-11-07 22:35:17 +0000182/// manager.
Devang Patel0ed47792006-11-10 21:33:13 +0000183bool CommonPassManagerImpl::manageablePass(Pass *P) {
Devang Patelf68a3492006-11-07 22:35:17 +0000184
185 AnalysisUsage AnUsage;
186 P->getAnalysisUsage(AnUsage);
187
Devang Patel6c9f5482006-11-11 00:42:16 +0000188 // If this pass is not preserving information that is required by the other
189 // passes managed by this manager then use new manager
190 if (!AnUsage.getPreservesAll()) {
191 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
192 for (std::vector<AnalysisID>::iterator I = RequiredAnalysis.begin(),
193 E = RequiredAnalysis.end(); I != E; ++I) {
194 if (std::find(PreservedSet.begin(), PreservedSet.end(), *I) ==
195 PreservedSet.end())
196 // This analysis is not preserved. Need new manager.
197 return false;
198 }
199 }
Devang Patelf68a3492006-11-07 22:35:17 +0000200 return true;
201}
202
Devang Pateld65e9e92006-11-08 01:31:28 +0000203/// Return true IFF AnalysisID AID is currently available.
Devang Patel0ed47792006-11-10 21:33:13 +0000204bool CommonPassManagerImpl::analysisCurrentlyAvailable(AnalysisID AID) {
Devang Patelf68a3492006-11-07 22:35:17 +0000205
206 // TODO
207 return false;
208}
209
Devang Patel643676c2006-11-11 01:10:19 +0000210/// Augment RequiredAnalysis by adding analysis required by pass P.
Devang Patel0ed47792006-11-10 21:33:13 +0000211void CommonPassManagerImpl::noteDownRequiredAnalysis(Pass *P) {
Devang Patel6c9f5482006-11-11 00:42:16 +0000212 AnalysisUsage AnUsage;
213 P->getAnalysisUsage(AnUsage);
214 const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
Devang Patelf68a3492006-11-07 22:35:17 +0000215
Devang Patel6c9f5482006-11-11 00:42:16 +0000216 // FIXME: What about duplicates ?
Devang Patel349170f2006-11-11 01:24:55 +0000217 RequiredAnalysis.insert(RequiredAnalysis.end(), RequiredSet.begin(),
218 RequiredSet.end());
Devang Patelf68a3492006-11-07 22:35:17 +0000219}
220
Devang Patel643676c2006-11-11 01:10:19 +0000221/// Augement AvailableAnalysis by adding analysis made available by pass P.
222void CommonPassManagerImpl::noteDownAvailableAnalysis(Pass *P) {
223
224 if (const PassInfo *PI = P->getPassInfo()) {
225 AvailableAnalysis.insert(PI);
226
227 //TODO This pass is the current implementation of all of the interfaces it
228 //TODO implements as well.
229 //TODO
230 //TODO const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
231 //TODO for (unsigned i = 0, e = II.size(); i != e; ++i)
232 //TODO CurrentAnalyses[II[i]] = P;
233 }
234}
235
Devang Patelf68a3492006-11-07 22:35:17 +0000236/// Remove AnalysisID from the RequiredSet
Devang Patel0ed47792006-11-10 21:33:13 +0000237void CommonPassManagerImpl::removeAnalysis(AnalysisID AID) {
Devang Patelf68a3492006-11-07 22:35:17 +0000238
239 // TODO
240}
241
242/// Remove Analyss not preserved by Pass P
Devang Patel0ed47792006-11-10 21:33:13 +0000243void CommonPassManagerImpl::removeNotPreservedAnalysis(Pass *P) {
Devang Patel349170f2006-11-11 01:24:55 +0000244 AnalysisUsage AnUsage;
245 P->getAnalysisUsage(AnUsage);
246 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
Devang Patelf68a3492006-11-07 22:35:17 +0000247
Devang Patel349170f2006-11-11 01:24:55 +0000248 for (std::set<AnalysisID>::iterator I = AvailableAnalysis.begin(),
249 E = AvailableAnalysis.end(); I != E; ++I ) {
Devang Patel349170f2006-11-11 01:24:55 +0000250 if (std::find(PreservedSet.begin(), PreservedSet.end(), *I) ==
251 PreservedSet.end()) {
252 // Remove this analysis
253 std::set<AnalysisID>::iterator J = I++;
254 AvailableAnalysis.erase(J);
255 }
256 }
Devang Patelf68a3492006-11-07 22:35:17 +0000257}
258
Devang Patel8cad70d2006-11-11 01:51:02 +0000259/// Add pass P into the PassVector. Update RequiredAnalysis and
260/// AvailableAnalysis appropriately
261void CommonPassManagerImpl::addPassToManager (Pass *P) {
262
263 // Take a note of analysis required and made available by this pass
264 noteDownRequiredAnalysis(P);
265 noteDownAvailableAnalysis(P);
266
267 // Add pass
268 PassVector.push_back(P);
269
270 // Remove the analysis not preserved by this pass
271 removeNotPreservedAnalysis(P);
272}
273
Devang Patel6e5a1132006-11-07 21:31:57 +0000274/// BasicBlockPassManager implementation
275
Devang Pateld65e9e92006-11-08 01:31:28 +0000276/// Add pass P into PassVector and return true. If this pass is not
277/// manageable by this manager then return false.
Devang Patel6e5a1132006-11-07 21:31:57 +0000278bool
Devang Pateld65e9e92006-11-08 01:31:28 +0000279BasicBlockPassManager_New::addPass(Pass *P) {
Devang Patel6e5a1132006-11-07 21:31:57 +0000280
281 BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P);
282 if (!BP)
283 return false;
284
Devang Patel3c8eb622006-11-07 22:56:50 +0000285 // If this pass does not preserve anlysis that is used by other passes
286 // managed by this manager than it is not a suiable pass for this manager.
Devang Pateld65e9e92006-11-08 01:31:28 +0000287 if (!manageablePass(P))
Devang Patel3c8eb622006-11-07 22:56:50 +0000288 return false;
289
Devang Patel8cad70d2006-11-11 01:51:02 +0000290 addPassToManager (BP);
Devang Patel349170f2006-11-11 01:24:55 +0000291
Devang Patel6e5a1132006-11-07 21:31:57 +0000292 return true;
293}
294
295/// Execute all of the passes scheduled for execution by invoking
296/// runOnBasicBlock method. Keep track of whether any of the passes modifies
297/// the function, and if so, return true.
298bool
299BasicBlockPassManager_New::runOnFunction(Function &F) {
300
301 bool Changed = false;
302 for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
Devang Patel8cad70d2006-11-11 01:51:02 +0000303 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
304 e = passVectorEnd(); itr != e; ++itr) {
Devang Patel6e5a1132006-11-07 21:31:57 +0000305 Pass *P = *itr;
306 BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P);
307 Changed |= BP->runOnBasicBlock(*I);
308 }
309 return Changed;
310}
311
Devang Patel0c2012f2006-11-07 21:49:50 +0000312// FunctionPassManager_New implementation
Devang Patel4e12f862006-11-08 10:44:40 +0000313/// Create new Function pass manager
314FunctionPassManager_New::FunctionPassManager_New() {
315 FPM = new FunctionPassManagerImpl_New();
316}
317
318/// add - Add a pass to the queue of passes to run. This passes
319/// ownership of the Pass to the PassManager. When the
320/// PassManager_X is destroyed, the pass will be destroyed as well, so
321/// there is no need to delete the pass. (TODO delete passes.)
322/// This implies that all passes MUST be allocated with 'new'.
323void
324FunctionPassManager_New::add(Pass *P) {
325 FPM->add(P);
326}
327
328/// Execute all of the passes scheduled for execution. Keep
329/// track of whether any of the passes modifies the function, and if
330/// so, return true.
331bool
332FunctionPassManager_New::runOnModule(Module &M) {
333 return FPM->runOnModule(M);
334}
335
336// FunctionPassManagerImpl_New implementation
Devang Patel0c2012f2006-11-07 21:49:50 +0000337
Devang Patel0c2012f2006-11-07 21:49:50 +0000338// FunctionPassManager
339
340/// Add pass P into the pass manager queue. If P is a BasicBlockPass then
341/// either use it into active basic block pass manager or create new basic
342/// block pass manager to handle pass P.
343bool
Devang Patel4e12f862006-11-08 10:44:40 +0000344FunctionPassManagerImpl_New::addPass(Pass *P) {
Devang Patel0c2012f2006-11-07 21:49:50 +0000345
346 // If P is a BasicBlockPass then use BasicBlockPassManager_New.
347 if (BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P)) {
348
349 if (!activeBBPassManager
350 || !activeBBPassManager->addPass(BP)) {
351
352 activeBBPassManager = new BasicBlockPassManager_New();
Devang Patel8cad70d2006-11-11 01:51:02 +0000353 addPassToManager(activeBBPassManager);
Devang Pateld65e9e92006-11-08 01:31:28 +0000354 if (!activeBBPassManager->addPass(BP))
355 assert(0 && "Unable to add Pass");
Devang Patel0c2012f2006-11-07 21:49:50 +0000356 }
357 return true;
358 }
359
360 FunctionPass *FP = dynamic_cast<FunctionPass *>(P);
361 if (!FP)
362 return false;
363
Devang Patel3c8eb622006-11-07 22:56:50 +0000364 // If this pass does not preserve anlysis that is used by other passes
365 // managed by this manager than it is not a suiable pass for this manager.
Devang Pateld65e9e92006-11-08 01:31:28 +0000366 if (!manageablePass(P))
Devang Patel3c8eb622006-11-07 22:56:50 +0000367 return false;
368
Devang Patel8cad70d2006-11-11 01:51:02 +0000369 addPassToManager (FP);
Devang Patel0c2012f2006-11-07 21:49:50 +0000370 activeBBPassManager = NULL;
371 return true;
372}
373
374/// Execute all of the passes scheduled for execution by invoking
375/// runOnFunction method. Keep track of whether any of the passes modifies
376/// the function, and if so, return true.
377bool
Devang Patel4e12f862006-11-08 10:44:40 +0000378FunctionPassManagerImpl_New::runOnModule(Module &M) {
Devang Patel0c2012f2006-11-07 21:49:50 +0000379
380 bool Changed = false;
381 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
Devang Patel8cad70d2006-11-11 01:51:02 +0000382 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
383 e = passVectorEnd(); itr != e; ++itr) {
Devang Patel0c2012f2006-11-07 21:49:50 +0000384 Pass *P = *itr;
385 FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
386 Changed |= FP->runOnFunction(*I);
387 }
388 return Changed;
389}
390
391
Devang Patel05e1a972006-11-07 22:03:15 +0000392// ModulePassManager implementation
393
394/// Add P into pass vector if it is manageble. If P is a FunctionPass
Devang Patel4e12f862006-11-08 10:44:40 +0000395/// then use FunctionPassManagerImpl_New to manage it. Return false if P
Devang Patel05e1a972006-11-07 22:03:15 +0000396/// is not manageable by this manager.
397bool
Devang Pateld65e9e92006-11-08 01:31:28 +0000398ModulePassManager_New::addPass(Pass *P) {
Devang Patel05e1a972006-11-07 22:03:15 +0000399
400 // If P is FunctionPass then use function pass maanager.
401 if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P)) {
402
403 activeFunctionPassManager = NULL;
404
405 if (!activeFunctionPassManager
406 || !activeFunctionPassManager->addPass(P)) {
407
Devang Patel4e12f862006-11-08 10:44:40 +0000408 activeFunctionPassManager = new FunctionPassManagerImpl_New();
Devang Patel8cad70d2006-11-11 01:51:02 +0000409 addPassToManager(activeFunctionPassManager);
Devang Pateld65e9e92006-11-08 01:31:28 +0000410 if (!activeFunctionPassManager->addPass(FP))
411 assert(0 && "Unable to add pass");
Devang Patel05e1a972006-11-07 22:03:15 +0000412 }
413 return true;
414 }
415
416 ModulePass *MP = dynamic_cast<ModulePass *>(P);
417 if (!MP)
418 return false;
419
Devang Patel3c8eb622006-11-07 22:56:50 +0000420 // If this pass does not preserve anlysis that is used by other passes
421 // managed by this manager than it is not a suiable pass for this manager.
Devang Pateld65e9e92006-11-08 01:31:28 +0000422 if (!manageablePass(P))
Devang Patel3c8eb622006-11-07 22:56:50 +0000423 return false;
424
Devang Patel8cad70d2006-11-11 01:51:02 +0000425 addPassToManager(MP);
Devang Patel05e1a972006-11-07 22:03:15 +0000426 activeFunctionPassManager = NULL;
427 return true;
428}
429
430
431/// Execute all of the passes scheduled for execution by invoking
432/// runOnModule method. Keep track of whether any of the passes modifies
433/// the module, and if so, return true.
434bool
435ModulePassManager_New::runOnModule(Module &M) {
436 bool Changed = false;
Devang Patel8cad70d2006-11-11 01:51:02 +0000437 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
438 e = passVectorEnd(); itr != e; ++itr) {
Devang Patel05e1a972006-11-07 22:03:15 +0000439 Pass *P = *itr;
440 ModulePass *MP = dynamic_cast<ModulePass*>(P);
441 Changed |= MP->runOnModule(M);
442 }
443 return Changed;
444}
445
Devang Patelc290c8a2006-11-07 22:23:34 +0000446/// Schedule all passes from the queue by adding them in their
447/// respective manager's queue.
448void
Devang Patel376fefa2006-11-08 10:29:57 +0000449PassManagerImpl_New::schedulePasses() {
Devang Patelc290c8a2006-11-07 22:23:34 +0000450 /* TODO */
451}
452
453/// Add pass P to the queue of passes to run.
454void
Devang Patel376fefa2006-11-08 10:29:57 +0000455PassManagerImpl_New::add(Pass *P) {
Devang Patelc290c8a2006-11-07 22:23:34 +0000456 /* TODO */
457}
458
459// PassManager_New implementation
460/// Add P into active pass manager or use new module pass manager to
461/// manage it.
462bool
Devang Patel376fefa2006-11-08 10:29:57 +0000463PassManagerImpl_New::addPass(Pass *P) {
Devang Patelc290c8a2006-11-07 22:23:34 +0000464
Devang Patel6c9f5482006-11-11 00:42:16 +0000465 if (!activeManager || !activeManager->addPass(P)) {
Devang Patelc290c8a2006-11-07 22:23:34 +0000466 activeManager = new ModulePassManager_New();
467 PassManagers.push_back(activeManager);
468 }
469
470 return activeManager->addPass(P);
471}
472
473/// run - Execute all of the passes scheduled for execution. Keep track of
474/// whether any of the passes modifies the module, and if so, return true.
475bool
Devang Patel376fefa2006-11-08 10:29:57 +0000476PassManagerImpl_New::run(Module &M) {
Devang Patelc290c8a2006-11-07 22:23:34 +0000477
478 schedulePasses();
479 bool Changed = false;
480 for (std::vector<ModulePassManager_New *>::iterator itr = PassManagers.begin(),
481 e = PassManagers.end(); itr != e; ++itr) {
482 ModulePassManager_New *pm = *itr;
483 Changed |= pm->runOnModule(M);
484 }
485 return Changed;
486}
Devang Patel376fefa2006-11-08 10:29:57 +0000487
488/// Create new pass manager
489PassManager_New::PassManager_New() {
490 PM = new PassManagerImpl_New();
491}
492
493/// add - Add a pass to the queue of passes to run. This passes ownership of
494/// the Pass to the PassManager. When the PassManager is destroyed, the pass
495/// will be destroyed as well, so there is no need to delete the pass. This
496/// implies that all passes MUST be allocated with 'new'.
497void
498PassManager_New::add(Pass *P) {
499 PM->add(P);
500}
501
502/// run - Execute all of the passes scheduled for execution. Keep track of
503/// whether any of the passes modifies the module, and if so, return true.
504bool
505PassManager_New::run(Module &M) {
506 return PM->run(M);
507}
508