blob: 0dff67f27201de642e8247832672e63172c562c5 [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 Patelff631ae2006-11-15 01:27:05 +000017#include "llvm/ModuleProvider.h"
Bill Wendlingdfc91892006-11-28 02:09:03 +000018#include "llvm/Support/Streams.h"
Devang Patela9844592006-11-11 01:31:05 +000019#include <vector>
Devang Patelf60b5d92006-11-14 01:59:59 +000020#include <map>
Devang Patel6e5a1132006-11-07 21:31:57 +000021using namespace llvm;
22
Devang Patel6fea2852006-12-07 18:23:30 +000023//===----------------------------------------------------------------------===//
24// Overview:
25// The Pass Manager Infrastructure manages passes. It's responsibilities are:
26//
27// o Manage optimization pass execution order
28// o Make required Analysis information available before pass P is run
29// o Release memory occupied by dead passes
30// o If Analysis information is dirtied by a pass then regenerate Analysis
31// information before it is consumed by another pass.
32//
33// Pass Manager Infrastructure uses multipe pass managers. They are PassManager,
34// FunctionPassManager, ModulePassManager, BasicBlockPassManager. This class
35// hierarcy uses multiple inheritance but pass managers do not derive from
36// another pass manager.
37//
38// PassManager and FunctionPassManager are two top level pass manager that
39// represents the external interface of this entire pass manager infrastucture.
40//
41// Important classes :
42//
43// [o] class PMTopLevelManager;
44//
45// Two top level managers, PassManager and FunctionPassManager, derive from
46// PMTopLevelManager. PMTopLevelManager manages information used by top level
47// managers such as last user info.
48//
49// [o] class PMDataManager;
50//
51// PMDataManager manages information, e.g. list of available analysis info,
52// used by a pass manager to manage execution order of passes. It also provides
53// a place to implement common pass manager APIs. All pass managers derive from
54// PMDataManager.
55//
56// [o] class BasicBlockPassManager : public FunctionPass, public PMDataManager;
57//
58// BasicBlockPassManager manages BasicBlockPasses.
59//
60// [o] class FunctionPassManager;
61//
62// This is a external interface used by JIT to manage FunctionPasses. This
63// interface relies on FunctionPassManagerImpl to do all the tasks.
64//
65// [o] class FunctionPassManagerImpl : public ModulePass, PMDataManager,
66// public PMTopLevelManager;
67//
68// FunctionPassManagerImpl is a top level manager. It manages FunctionPasses
69// and BasicBlockPassManagers.
70//
71// [o] class ModulePassManager : public Pass, public PMDataManager;
72//
73// ModulePassManager manages ModulePasses and FunctionPassManagerImpls.
74//
75// [o] class PassManager;
76//
77// This is a external interface used by various tools to manages passes. It
78// relies on PassManagerImpl to do all the tasks.
79//
80// [o] class PassManagerImpl : public Pass, public PMDataManager,
81// public PMDTopLevelManager
82//
83// PassManagerImpl is a top level pass manager responsible for managing
84// ModulePassManagers.
85//===----------------------------------------------------------------------===//
86
Devang Patelca58e352006-11-08 10:05:38 +000087namespace llvm {
88
Devang Patelf33f3eb2006-12-07 19:21:29 +000089//===----------------------------------------------------------------------===//
90// PMTopLevelManager
91//
92/// PMTopLevelManager manages LastUser info and collects common APIs used by
93/// top level pass managers.
94class PMTopLevelManager {
95
96public:
97
98 inline std::vector<Pass *>::iterator passManagersBegin() {
99 return PassManagers.begin();
100 }
101
102 inline std::vector<Pass *>::iterator passManagersEnd() {
103 return PassManagers.end();
104 }
105
106 /// Schedule pass P for execution. Make sure that passes required by
107 /// P are run before P is run. Update analysis info maintained by
108 /// the manager. Remove dead passes. This is a recursive function.
109 void schedulePass(Pass *P, Pass *PM);
110
111 /// This is implemented by top level pass manager and used by
112 /// schedulePass() to add analysis info passes that are not available.
113 virtual void addTopLevelPass(Pass *P) = 0;
114
115 /// Set pass P as the last user of the given analysis passes.
116 void setLastUser(std::vector<Pass *> &AnalysisPasses, Pass *P);
117
118 /// Collect passes whose last user is P
119 void collectLastUses(std::vector<Pass *> &LastUses, Pass *P);
120
121 virtual ~PMTopLevelManager() {
122 PassManagers.clear();
123 }
124
125private:
126
127 /// Collection of pass managers
128 std::vector<Pass *> PassManagers;
129
130 // Map to keep track of last user of the analysis pass.
131 // LastUser->second is the last user of Lastuser->first.
132 std::map<Pass *, Pass *> LastUser;
133};
134
135/// Set pass P as the last user of the given analysis passes.
136void PMTopLevelManager::setLastUser(std::vector<Pass *> &AnalysisPasses,
137 Pass *P) {
138
139 for (std::vector<Pass *>::iterator I = AnalysisPasses.begin(),
140 E = AnalysisPasses.end(); I != E; ++I) {
141 Pass *AP = *I;
142 LastUser[AP] = P;
143 // If AP is the last user of other passes then make P last user of
144 // such passes.
145 for (std::map<Pass *, Pass *>::iterator LUI = LastUser.begin(),
146 LUE = LastUser.end(); LUI != LUE; ++LUI) {
147 if (LUI->second == AP)
148 LastUser[LUI->first] = P;
149 }
150 }
151
152}
153
154/// Collect passes whose last user is P
155void PMTopLevelManager::collectLastUses(std::vector<Pass *> &LastUses,
156 Pass *P) {
157 for (std::map<Pass *, Pass *>::iterator LUI = LastUser.begin(),
158 LUE = LastUser.end(); LUI != LUE; ++LUI)
159 if (LUI->second == P)
160 LastUses.push_back(LUI->first);
161}
162
Devang Patelf3827bc2006-12-07 19:54:15 +0000163//===----------------------------------------------------------------------===//
164// PMDataManager
Devang Patelf33f3eb2006-12-07 19:21:29 +0000165
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000166/// PMDataManager provides the common place to manage the analysis data
167/// used by pass managers.
168class PMDataManager {
Devang Patela9844592006-11-11 01:31:05 +0000169
170public:
171
Devang Patelf3827bc2006-12-07 19:54:15 +0000172 PMDataManager() : TPM(NULL) {
173 initializeAnalysisInfo();
174 }
175
Devang Patela9844592006-11-11 01:31:05 +0000176 /// Return true IFF pass P's required analysis set does not required new
177 /// manager.
178 bool manageablePass(Pass *P);
179
Devang Patelf60b5d92006-11-14 01:59:59 +0000180 Pass *getAnalysisPass(AnalysisID AID) const {
181
182 std::map<AnalysisID, Pass*>::const_iterator I =
183 AvailableAnalysis.find(AID);
184
185 if (I != AvailableAnalysis.end())
186 return NULL;
187 else
188 return I->second;
Devang Patelebba9702006-11-13 22:40:09 +0000189 }
Devang Patela9844592006-11-11 01:31:05 +0000190
Devang Patela9844592006-11-11 01:31:05 +0000191 /// Augment AvailableAnalysis by adding analysis made available by pass P.
Devang Patele9976aa2006-12-07 19:33:53 +0000192 void recordAvailableAnalysis(Pass *P);
Devang Patela9844592006-11-11 01:31:05 +0000193
Devang Patela9844592006-11-11 01:31:05 +0000194 /// Remove Analysis that is not preserved by the pass
195 void removeNotPreservedAnalysis(Pass *P);
196
197 /// Remove dead passes
Devang Patelca189262006-11-14 03:05:08 +0000198 void removeDeadPasses(Pass *P);
Devang Patela9844592006-11-11 01:31:05 +0000199
Devang Patel8f677ce2006-12-07 18:47:25 +0000200 /// Add pass P into the PassVector. Update
Devang Patel90b05e02006-11-11 02:04:19 +0000201 /// AvailableAnalysis appropriately if ProcessAnalysis is true.
202 void addPassToManager (Pass *P, bool ProcessAnalysis = true);
Devang Patel8cad70d2006-11-11 01:51:02 +0000203
Devang Patela6b6dcb2006-12-07 18:41:09 +0000204 // Initialize available analysis information.
205 void initializeAnalysisInfo() {
Devang Patel050ec722006-11-14 01:23:29 +0000206 AvailableAnalysis.clear();
Devang Patel3f0832a2006-11-14 02:54:23 +0000207 LastUser.clear();
Devang Patel050ec722006-11-14 01:23:29 +0000208 }
209
Devang Patelf60b5d92006-11-14 01:59:59 +0000210 // All Required analyses should be available to the pass as it runs! Here
211 // we fill in the AnalysisImpls member of the pass so that it can
212 // successfully use the getAnalysis() method to retrieve the
213 // implementations it needs.
214 //
Devang Patel07f4f582006-11-14 21:49:36 +0000215 void initializeAnalysisImpl(Pass *P);
Devang Patelf60b5d92006-11-14 01:59:59 +0000216
Devang Patel8cad70d2006-11-11 01:51:02 +0000217 inline std::vector<Pass *>::iterator passVectorBegin() {
218 return PassVector.begin();
219 }
220
221 inline std::vector<Pass *>::iterator passVectorEnd() {
222 return PassVector.end();
223 }
224
Devang Patel4a3fa4f2006-11-15 01:48:14 +0000225 inline void setLastUser(Pass *P, Pass *LU) {
Devang Patel07f4f582006-11-14 21:49:36 +0000226 LastUser[P] = LU;
227 // TODO : Check if pass P is available.
Devang Patel07f4f582006-11-14 21:49:36 +0000228 }
Devang Patel3f0832a2006-11-14 02:54:23 +0000229
Devang Patelf3827bc2006-12-07 19:54:15 +0000230 // Access toplevel manager
231 PMTopLevelManager *getTopLevelManager() { return TPM; }
232 void setTopLevelManager(PMTopLevelManager *T) { TPM = T; }
233
Devang Patela9844592006-11-11 01:31:05 +0000234private:
Devang Pateldafa4dd2006-11-14 00:03:04 +0000235 // Set of available Analysis. This information is used while scheduling
236 // pass. If a pass requires an analysis which is not not available then
237 // equired analysis pass is scheduled to run before the pass itself is
238 // scheduled to run.
Devang Patelf60b5d92006-11-14 01:59:59 +0000239 std::map<AnalysisID, Pass*> AvailableAnalysis;
Devang Patel8cad70d2006-11-11 01:51:02 +0000240
Devang Patel3f0832a2006-11-14 02:54:23 +0000241 // Map to keep track of last user of the analysis pass.
242 // LastUser->second is the last user of Lastuser->first.
243 std::map<Pass *, Pass *> LastUser;
244
Devang Patel8cad70d2006-11-11 01:51:02 +0000245 // Collection of pass that are managed by this manager
246 std::vector<Pass *> PassVector;
Devang Patelf3827bc2006-12-07 19:54:15 +0000247
248 // Top level manager.
249 // TODO : Make it a reference.
250 PMTopLevelManager *TPM;
Devang Patela9844592006-11-11 01:31:05 +0000251};
252
Devang Patelca58e352006-11-08 10:05:38 +0000253/// BasicBlockPassManager_New manages BasicBlockPass. It batches all the
254/// pass together and sequence them to process one basic block before
255/// processing next basic block.
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000256class BasicBlockPassManager_New : public PMDataManager,
Devang Patel42add712006-11-15 01:11:27 +0000257 public FunctionPass {
Devang Patelca58e352006-11-08 10:05:38 +0000258
259public:
260 BasicBlockPassManager_New() { }
261
262 /// Add a pass into a passmanager queue.
263 bool addPass(Pass *p);
264
265 /// Execute all of the passes scheduled for execution. Keep track of
266 /// whether any of the passes modifies the function, and if so, return true.
267 bool runOnFunction(Function &F);
268
Devang Patelebba9702006-11-13 22:40:09 +0000269 /// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000270 Pass *getAnalysisPassFromManager(AnalysisID AID);
Devang Patelebba9702006-11-13 22:40:09 +0000271
Devang Patelca58e352006-11-08 10:05:38 +0000272private:
Devang Patelca58e352006-11-08 10:05:38 +0000273};
274
Devang Patel4e12f862006-11-08 10:44:40 +0000275/// FunctionPassManagerImpl_New manages FunctionPasses and BasicBlockPassManagers.
Devang Patelca58e352006-11-08 10:05:38 +0000276/// It batches all function passes and basic block pass managers together and
277/// sequence them to process one function at a time before processing next
278/// function.
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000279class FunctionPassManagerImpl_New : public PMDataManager,
Devang Patel42add712006-11-15 01:11:27 +0000280 public ModulePass {
Devang Patelca58e352006-11-08 10:05:38 +0000281public:
Devang Patel4e12f862006-11-08 10:44:40 +0000282 FunctionPassManagerImpl_New(ModuleProvider *P) { /* TODO */ }
283 FunctionPassManagerImpl_New() {
Devang Patelca58e352006-11-08 10:05:38 +0000284 activeBBPassManager = NULL;
285 }
Devang Patel4e12f862006-11-08 10:44:40 +0000286 ~FunctionPassManagerImpl_New() { /* TODO */ };
Devang Patelca58e352006-11-08 10:05:38 +0000287
288 /// add - Add a pass to the queue of passes to run. This passes
289 /// ownership of the Pass to the PassManager. When the
290 /// PassManager_X is destroyed, the pass will be destroyed as well, so
291 /// there is no need to delete the pass. (TODO delete passes.)
292 /// This implies that all passes MUST be allocated with 'new'.
293 void add(Pass *P) { /* TODO*/ }
294
295 /// Add pass into the pass manager queue.
296 bool addPass(Pass *P);
297
298 /// Execute all of the passes scheduled for execution. Keep
299 /// track of whether any of the passes modifies the function, and if
300 /// so, return true.
301 bool runOnModule(Module &M);
Devang Patel9f3083e2006-11-15 19:39:54 +0000302 bool runOnFunction(Function &F);
Devang Patelca58e352006-11-08 10:05:38 +0000303
Devang Patelebba9702006-11-13 22:40:09 +0000304 /// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000305 Pass *getAnalysisPassFromManager(AnalysisID AID);
Devang Patelebba9702006-11-13 22:40:09 +0000306
Devang Patelff631ae2006-11-15 01:27:05 +0000307 /// doInitialization - Run all of the initializers for the function passes.
308 ///
309 bool doInitialization(Module &M);
310
311 /// doFinalization - Run all of the initializers for the function passes.
312 ///
313 bool doFinalization(Module &M);
Devang Patelca58e352006-11-08 10:05:38 +0000314private:
Devang Patelca58e352006-11-08 10:05:38 +0000315 // Active Pass Managers
316 BasicBlockPassManager_New *activeBBPassManager;
317};
318
319/// ModulePassManager_New manages ModulePasses and function pass managers.
320/// It batches all Module passes passes and function pass managers together and
321/// sequence them to process one module.
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000322class ModulePassManager_New : public PMDataManager {
Devang Patelca58e352006-11-08 10:05:38 +0000323
324public:
325 ModulePassManager_New() { activeFunctionPassManager = NULL; }
326
327 /// Add a pass into a passmanager queue.
328 bool addPass(Pass *p);
329
330 /// run - Execute all of the passes scheduled for execution. Keep track of
331 /// whether any of the passes modifies the module, and if so, return true.
332 bool runOnModule(Module &M);
Devang Patelebba9702006-11-13 22:40:09 +0000333
334 /// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000335 Pass *getAnalysisPassFromManager(AnalysisID AID);
Devang Patelca58e352006-11-08 10:05:38 +0000336
337private:
Devang Patelca58e352006-11-08 10:05:38 +0000338 // Active Pass Manager
Devang Patel4e12f862006-11-08 10:44:40 +0000339 FunctionPassManagerImpl_New *activeFunctionPassManager;
Devang Patelca58e352006-11-08 10:05:38 +0000340};
341
Devang Patel376fefa2006-11-08 10:29:57 +0000342/// PassManager_New manages ModulePassManagers
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000343class PassManagerImpl_New : public PMDataManager {
Devang Patel376fefa2006-11-08 10:29:57 +0000344
345public:
346
347 /// add - Add a pass to the queue of passes to run. This passes ownership of
348 /// the Pass to the PassManager. When the PassManager is destroyed, the pass
349 /// will be destroyed as well, so there is no need to delete the pass. This
350 /// implies that all passes MUST be allocated with 'new'.
351 void add(Pass *P);
352
353 /// run - Execute all of the passes scheduled for execution. Keep track of
354 /// whether any of the passes modifies the module, and if so, return true.
355 bool run(Module &M);
356
Devang Patelebba9702006-11-13 22:40:09 +0000357 /// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000358 Pass *getAnalysisPassFromManager(AnalysisID AID);
Devang Patelebba9702006-11-13 22:40:09 +0000359
Devang Patel376fefa2006-11-08 10:29:57 +0000360private:
361
362 /// Add a pass into a passmanager queue. This is used by schedulePasses
363 bool addPass(Pass *p);
364
Devang Patel1a6eaa42006-11-11 02:22:31 +0000365 /// Schedule pass P for execution. Make sure that passes required by
366 /// P are run before P is run. Update analysis info maintained by
367 /// the manager. Remove dead passes. This is a recursive function.
368 void schedulePass(Pass *P);
369
Devang Patel376fefa2006-11-08 10:29:57 +0000370 /// Schedule all passes collected in pass queue using add(). Add all the
371 /// schedule passes into various manager's queue using addPass().
372 void schedulePasses();
373
374 // Collection of pass managers
375 std::vector<ModulePassManager_New *> PassManagers;
376
Devang Patel376fefa2006-11-08 10:29:57 +0000377 // Active Pass Manager
378 ModulePassManager_New *activeManager;
379};
380
Devang Patelca58e352006-11-08 10:05:38 +0000381} // End of llvm namespace
382
Devang Patela1514cb2006-12-07 19:39:39 +0000383//===----------------------------------------------------------------------===//
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000384// PMDataManager implementation
Devang Patelf68a3492006-11-07 22:35:17 +0000385
Devang Pateld65e9e92006-11-08 01:31:28 +0000386/// Return true IFF pass P's required analysis set does not required new
Devang Patelf68a3492006-11-07 22:35:17 +0000387/// manager.
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000388bool PMDataManager::manageablePass(Pass *P) {
Devang Patelf68a3492006-11-07 22:35:17 +0000389
Devang Patel8f677ce2006-12-07 18:47:25 +0000390 // TODO
391 // If this pass is not preserving information that is required by a
392 // pass maintained by higher level pass manager then do not insert
393 // this pass into current manager. Use new manager. For example,
394 // For example, If FunctionPass F is not preserving ModulePass Info M1
395 // that is used by another ModulePass M2 then do not insert F in
396 // current function pass manager.
Devang Patelf68a3492006-11-07 22:35:17 +0000397 return true;
398}
399
Devang Patel643676c2006-11-11 01:10:19 +0000400/// Augement AvailableAnalysis by adding analysis made available by pass P.
Devang Patele9976aa2006-12-07 19:33:53 +0000401void PMDataManager::recordAvailableAnalysis(Pass *P) {
Devang Patelf60b5d92006-11-14 01:59:59 +0000402
Devang Patel643676c2006-11-11 01:10:19 +0000403 if (const PassInfo *PI = P->getPassInfo()) {
Devang Patelf60b5d92006-11-14 01:59:59 +0000404 AvailableAnalysis[PI] = P;
Devang Patel643676c2006-11-11 01:10:19 +0000405
Devang Patele9976aa2006-12-07 19:33:53 +0000406 //This pass is the current implementation of all of the interfaces it
407 //implements as well.
408 const std::vector<const PassInfo*> &II = PI->getInterfacesImplemented();
409 for (unsigned i = 0, e = II.size(); i != e; ++i)
410 AvailableAnalysis[II[i]] = P;
Devang Patel643676c2006-11-11 01:10:19 +0000411 }
412}
413
Devang Patelf68a3492006-11-07 22:35:17 +0000414/// Remove Analyss not preserved by Pass P
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000415void PMDataManager::removeNotPreservedAnalysis(Pass *P) {
Devang Patel349170f2006-11-11 01:24:55 +0000416 AnalysisUsage AnUsage;
417 P->getAnalysisUsage(AnUsage);
418 const std::vector<AnalysisID> &PreservedSet = AnUsage.getPreservedSet();
Devang Patelf68a3492006-11-07 22:35:17 +0000419
Devang Patelf60b5d92006-11-14 01:59:59 +0000420 for (std::map<AnalysisID, Pass*>::iterator I = AvailableAnalysis.begin(),
Devang Patel349170f2006-11-11 01:24:55 +0000421 E = AvailableAnalysis.end(); I != E; ++I ) {
Devang Patelf60b5d92006-11-14 01:59:59 +0000422 if (std::find(PreservedSet.begin(), PreservedSet.end(), I->first) ==
Devang Patel349170f2006-11-11 01:24:55 +0000423 PreservedSet.end()) {
424 // Remove this analysis
Devang Patelf60b5d92006-11-14 01:59:59 +0000425 std::map<AnalysisID, Pass*>::iterator J = I++;
Devang Patel349170f2006-11-11 01:24:55 +0000426 AvailableAnalysis.erase(J);
427 }
428 }
Devang Patelf68a3492006-11-07 22:35:17 +0000429}
430
Devang Patelca189262006-11-14 03:05:08 +0000431/// Remove analysis passes that are not used any longer
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000432void PMDataManager::removeDeadPasses(Pass *P) {
Devang Patelca189262006-11-14 03:05:08 +0000433
434 for (std::map<Pass *, Pass *>::iterator I = LastUser.begin(),
435 E = LastUser.end(); I !=E; ++I) {
436 if (I->second == P) {
437 Pass *deadPass = I->first;
438 deadPass->releaseMemory();
439
440 std::map<AnalysisID, Pass*>::iterator Pos =
441 AvailableAnalysis.find(deadPass->getPassInfo());
442
443 assert (Pos != AvailableAnalysis.end() &&
444 "Pass is not available");
445 AvailableAnalysis.erase(Pos);
446 }
447 }
448}
449
Devang Patel8f677ce2006-12-07 18:47:25 +0000450/// Add pass P into the PassVector. Update
Devang Patel90b05e02006-11-11 02:04:19 +0000451/// AvailableAnalysis appropriately if ProcessAnalysis is true.
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000452void PMDataManager::addPassToManager (Pass *P,
Devang Patel90b05e02006-11-11 02:04:19 +0000453 bool ProcessAnalysis) {
Devang Patel8cad70d2006-11-11 01:51:02 +0000454
Devang Patel90b05e02006-11-11 02:04:19 +0000455 if (ProcessAnalysis) {
456 // Take a note of analysis required and made available by this pass
Devang Patel8f677ce2006-12-07 18:47:25 +0000457 initializeAnalysisImpl(P);
Devang Patele9976aa2006-12-07 19:33:53 +0000458 recordAvailableAnalysis(P);
Devang Patel90b05e02006-11-11 02:04:19 +0000459
460 // Remove the analysis not preserved by this pass
461 removeNotPreservedAnalysis(P);
462 }
Devang Patel8cad70d2006-11-11 01:51:02 +0000463
464 // Add pass
465 PassVector.push_back(P);
Devang Patel8cad70d2006-11-11 01:51:02 +0000466}
467
Devang Patel07f4f582006-11-14 21:49:36 +0000468// All Required analyses should be available to the pass as it runs! Here
469// we fill in the AnalysisImpls member of the pass so that it can
470// successfully use the getAnalysis() method to retrieve the
471// implementations it needs.
472//
Devang Pateldbe4a1e2006-12-07 18:36:24 +0000473void PMDataManager::initializeAnalysisImpl(Pass *P) {
Devang Patelff631ae2006-11-15 01:27:05 +0000474 AnalysisUsage AnUsage;
475 P->getAnalysisUsage(AnUsage);
Devang Patel07f4f582006-11-14 21:49:36 +0000476
477 for (std::vector<const PassInfo *>::const_iterator
478 I = AnUsage.getRequiredSet().begin(),
479 E = AnUsage.getRequiredSet().end(); I != E; ++I) {
480 Pass *Impl = getAnalysisPass(*I);
481 if (Impl == 0)
482 assert(0 && "Analysis used but not available!");
483 // TODO: P->AnalysisImpls.push_back(std::make_pair(*I, Impl));
484 }
485}
486
Devang Patela1514cb2006-12-07 19:39:39 +0000487//===----------------------------------------------------------------------===//
488// BasicBlockPassManager_New implementation
Devang Patel6e5a1132006-11-07 21:31:57 +0000489
Devang Pateld65e9e92006-11-08 01:31:28 +0000490/// Add pass P into PassVector and return true. If this pass is not
491/// manageable by this manager then return false.
Devang Patel6e5a1132006-11-07 21:31:57 +0000492bool
Devang Pateld65e9e92006-11-08 01:31:28 +0000493BasicBlockPassManager_New::addPass(Pass *P) {
Devang Patel6e5a1132006-11-07 21:31:57 +0000494
495 BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P);
496 if (!BP)
497 return false;
498
Devang Patel3c8eb622006-11-07 22:56:50 +0000499 // If this pass does not preserve anlysis that is used by other passes
500 // managed by this manager than it is not a suiable pass for this manager.
Devang Pateld65e9e92006-11-08 01:31:28 +0000501 if (!manageablePass(P))
Devang Patel3c8eb622006-11-07 22:56:50 +0000502 return false;
503
Devang Patel8cad70d2006-11-11 01:51:02 +0000504 addPassToManager (BP);
Devang Patel349170f2006-11-11 01:24:55 +0000505
Devang Patel6e5a1132006-11-07 21:31:57 +0000506 return true;
507}
508
509/// Execute all of the passes scheduled for execution by invoking
510/// runOnBasicBlock method. Keep track of whether any of the passes modifies
511/// the function, and if so, return true.
512bool
513BasicBlockPassManager_New::runOnFunction(Function &F) {
514
515 bool Changed = false;
Devang Patela6b6dcb2006-12-07 18:41:09 +0000516 initializeAnalysisInfo();
Devang Patel050ec722006-11-14 01:23:29 +0000517
Devang Patel6e5a1132006-11-07 21:31:57 +0000518 for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
Devang Patel8cad70d2006-11-11 01:51:02 +0000519 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
520 e = passVectorEnd(); itr != e; ++itr) {
Devang Patel6e5a1132006-11-07 21:31:57 +0000521 Pass *P = *itr;
Devang Patel050ec722006-11-14 01:23:29 +0000522
Devang Patele9976aa2006-12-07 19:33:53 +0000523 recordAvailableAnalysis(P);
Devang Patel6e5a1132006-11-07 21:31:57 +0000524 BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P);
525 Changed |= BP->runOnBasicBlock(*I);
Devang Patel050ec722006-11-14 01:23:29 +0000526 removeNotPreservedAnalysis(P);
Devang Patelca189262006-11-14 03:05:08 +0000527 removeDeadPasses(P);
Devang Patel6e5a1132006-11-07 21:31:57 +0000528 }
529 return Changed;
530}
531
Devang Patelebba9702006-11-13 22:40:09 +0000532/// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000533Pass * BasicBlockPassManager_New::getAnalysisPassFromManager(AnalysisID AID) {
534 return getAnalysisPass(AID);
Devang Patelebba9702006-11-13 22:40:09 +0000535}
536
Devang Patela1514cb2006-12-07 19:39:39 +0000537//===----------------------------------------------------------------------===//
Devang Patel0c2012f2006-11-07 21:49:50 +0000538// FunctionPassManager_New implementation
Devang Patela1514cb2006-12-07 19:39:39 +0000539
Devang Patel4e12f862006-11-08 10:44:40 +0000540/// Create new Function pass manager
541FunctionPassManager_New::FunctionPassManager_New() {
542 FPM = new FunctionPassManagerImpl_New();
543}
544
545/// add - Add a pass to the queue of passes to run. This passes
546/// ownership of the Pass to the PassManager. When the
547/// PassManager_X is destroyed, the pass will be destroyed as well, so
548/// there is no need to delete the pass. (TODO delete passes.)
549/// This implies that all passes MUST be allocated with 'new'.
Devang Patel9f3083e2006-11-15 19:39:54 +0000550void FunctionPassManager_New::add(Pass *P) {
Devang Patel4e12f862006-11-08 10:44:40 +0000551 FPM->add(P);
552}
553
554/// Execute all of the passes scheduled for execution. Keep
555/// track of whether any of the passes modifies the function, and if
556/// so, return true.
Devang Patel9f3083e2006-11-15 19:39:54 +0000557bool FunctionPassManager_New::runOnModule(Module &M) {
Devang Patel4e12f862006-11-08 10:44:40 +0000558 return FPM->runOnModule(M);
559}
560
Devang Patel9f3083e2006-11-15 19:39:54 +0000561/// run - Execute all of the passes scheduled for execution. Keep
562/// track of whether any of the passes modifies the function, and if
563/// so, return true.
564///
565bool FunctionPassManager_New::run(Function &F) {
566 std::string errstr;
567 if (MP->materializeFunction(&F, &errstr)) {
Bill Wendlingf3baad32006-12-07 01:30:32 +0000568 cerr << "Error reading bytecode file: " << errstr << "\n";
Devang Patel9f3083e2006-11-15 19:39:54 +0000569 abort();
570 }
571 return FPM->runOnFunction(F);
572}
573
574
Devang Patelff631ae2006-11-15 01:27:05 +0000575/// doInitialization - Run all of the initializers for the function passes.
576///
577bool FunctionPassManager_New::doInitialization() {
578 return FPM->doInitialization(*MP->getModule());
579}
580
581/// doFinalization - Run all of the initializers for the function passes.
582///
583bool FunctionPassManager_New::doFinalization() {
584 return FPM->doFinalization(*MP->getModule());
585}
586
Devang Patela1514cb2006-12-07 19:39:39 +0000587//===----------------------------------------------------------------------===//
Devang Patel4e12f862006-11-08 10:44:40 +0000588// FunctionPassManagerImpl_New implementation
Devang Patel0c2012f2006-11-07 21:49:50 +0000589
Devang Patel0c2012f2006-11-07 21:49:50 +0000590/// Add pass P into the pass manager queue. If P is a BasicBlockPass then
591/// either use it into active basic block pass manager or create new basic
592/// block pass manager to handle pass P.
593bool
Devang Patel4e12f862006-11-08 10:44:40 +0000594FunctionPassManagerImpl_New::addPass(Pass *P) {
Devang Patel0c2012f2006-11-07 21:49:50 +0000595
596 // If P is a BasicBlockPass then use BasicBlockPassManager_New.
597 if (BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P)) {
598
599 if (!activeBBPassManager
600 || !activeBBPassManager->addPass(BP)) {
601
602 activeBBPassManager = new BasicBlockPassManager_New();
Devang Patel90b05e02006-11-11 02:04:19 +0000603 addPassToManager(activeBBPassManager, false);
Devang Pateld65e9e92006-11-08 01:31:28 +0000604 if (!activeBBPassManager->addPass(BP))
605 assert(0 && "Unable to add Pass");
Devang Patel0c2012f2006-11-07 21:49:50 +0000606 }
607 return true;
608 }
609
610 FunctionPass *FP = dynamic_cast<FunctionPass *>(P);
611 if (!FP)
612 return false;
613
Devang Patel3c8eb622006-11-07 22:56:50 +0000614 // If this pass does not preserve anlysis that is used by other passes
615 // managed by this manager than it is not a suiable pass for this manager.
Devang Pateld65e9e92006-11-08 01:31:28 +0000616 if (!manageablePass(P))
Devang Patel3c8eb622006-11-07 22:56:50 +0000617 return false;
618
Devang Patel8cad70d2006-11-11 01:51:02 +0000619 addPassToManager (FP);
Devang Patel0c2012f2006-11-07 21:49:50 +0000620 activeBBPassManager = NULL;
621 return true;
622}
623
624/// Execute all of the passes scheduled for execution by invoking
625/// runOnFunction method. Keep track of whether any of the passes modifies
626/// the function, and if so, return true.
Devang Patel9f3083e2006-11-15 19:39:54 +0000627bool FunctionPassManagerImpl_New::runOnModule(Module &M) {
Devang Patel0c2012f2006-11-07 21:49:50 +0000628
629 bool Changed = false;
Devang Patela6b6dcb2006-12-07 18:41:09 +0000630 initializeAnalysisInfo();
Devang Patel050ec722006-11-14 01:23:29 +0000631
Devang Patel0c2012f2006-11-07 21:49:50 +0000632 for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
Devang Patel8cad70d2006-11-11 01:51:02 +0000633 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
634 e = passVectorEnd(); itr != e; ++itr) {
Devang Patel0c2012f2006-11-07 21:49:50 +0000635 Pass *P = *itr;
Devang Patel050ec722006-11-14 01:23:29 +0000636
Devang Patele9976aa2006-12-07 19:33:53 +0000637 recordAvailableAnalysis(P);
Devang Patel0c2012f2006-11-07 21:49:50 +0000638 FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
639 Changed |= FP->runOnFunction(*I);
Devang Patel050ec722006-11-14 01:23:29 +0000640 removeNotPreservedAnalysis(P);
Devang Patelca189262006-11-14 03:05:08 +0000641 removeDeadPasses(P);
Devang Patel0c2012f2006-11-07 21:49:50 +0000642 }
643 return Changed;
644}
645
Devang Patel9f3083e2006-11-15 19:39:54 +0000646/// Execute all of the passes scheduled for execution by invoking
647/// runOnFunction method. Keep track of whether any of the passes modifies
648/// the function, and if so, return true.
649bool FunctionPassManagerImpl_New::runOnFunction(Function &F) {
650
651 bool Changed = false;
Devang Patela6b6dcb2006-12-07 18:41:09 +0000652 initializeAnalysisInfo();
Devang Patel9f3083e2006-11-15 19:39:54 +0000653
654 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
655 e = passVectorEnd(); itr != e; ++itr) {
656 Pass *P = *itr;
657
Devang Patele9976aa2006-12-07 19:33:53 +0000658 recordAvailableAnalysis(P);
Devang Patel9f3083e2006-11-15 19:39:54 +0000659 FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
660 Changed |= FP->runOnFunction(F);
661 removeNotPreservedAnalysis(P);
662 removeDeadPasses(P);
663 }
664 return Changed;
665}
666
667
Devang Patelebba9702006-11-13 22:40:09 +0000668/// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000669Pass *FunctionPassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) {
Devang Patelebba9702006-11-13 22:40:09 +0000670
Devang Patel3f0832a2006-11-14 02:54:23 +0000671 Pass *P = getAnalysisPass(AID);
672 if (P)
673 return P;
Devang Patelebba9702006-11-13 22:40:09 +0000674
675 if (activeBBPassManager &&
Devang Patelf60b5d92006-11-14 01:59:59 +0000676 activeBBPassManager->getAnalysisPass(AID) != 0)
Devang Patel3f0832a2006-11-14 02:54:23 +0000677 return activeBBPassManager->getAnalysisPass(AID);
Devang Patelebba9702006-11-13 22:40:09 +0000678
679 // TODO : Check inactive managers
Devang Patel3f0832a2006-11-14 02:54:23 +0000680 return NULL;
Devang Patelebba9702006-11-13 22:40:09 +0000681}
Devang Patel0c2012f2006-11-07 21:49:50 +0000682
Devang Patelff631ae2006-11-15 01:27:05 +0000683inline bool FunctionPassManagerImpl_New::doInitialization(Module &M) {
684 bool Changed = false;
685
686 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
687 e = passVectorEnd(); itr != e; ++itr) {
688 Pass *P = *itr;
689
690 FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
691 Changed |= FP->doInitialization(M);
692 }
693
694 return Changed;
695}
696
697inline bool FunctionPassManagerImpl_New::doFinalization(Module &M) {
698 bool Changed = false;
699
700 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
701 e = passVectorEnd(); itr != e; ++itr) {
702 Pass *P = *itr;
703
704 FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
705 Changed |= FP->doFinalization(M);
706 }
707
708
709 return Changed;
710}
711
Devang Patela1514cb2006-12-07 19:39:39 +0000712//===----------------------------------------------------------------------===//
Devang Patel05e1a972006-11-07 22:03:15 +0000713// ModulePassManager implementation
714
715/// Add P into pass vector if it is manageble. If P is a FunctionPass
Devang Patel4e12f862006-11-08 10:44:40 +0000716/// then use FunctionPassManagerImpl_New to manage it. Return false if P
Devang Patel05e1a972006-11-07 22:03:15 +0000717/// is not manageable by this manager.
718bool
Devang Pateld65e9e92006-11-08 01:31:28 +0000719ModulePassManager_New::addPass(Pass *P) {
Devang Patel05e1a972006-11-07 22:03:15 +0000720
721 // If P is FunctionPass then use function pass maanager.
722 if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P)) {
723
724 activeFunctionPassManager = NULL;
725
726 if (!activeFunctionPassManager
727 || !activeFunctionPassManager->addPass(P)) {
728
Devang Patel4e12f862006-11-08 10:44:40 +0000729 activeFunctionPassManager = new FunctionPassManagerImpl_New();
Devang Patel90b05e02006-11-11 02:04:19 +0000730 addPassToManager(activeFunctionPassManager, false);
Devang Pateld65e9e92006-11-08 01:31:28 +0000731 if (!activeFunctionPassManager->addPass(FP))
732 assert(0 && "Unable to add pass");
Devang Patel05e1a972006-11-07 22:03:15 +0000733 }
734 return true;
735 }
736
737 ModulePass *MP = dynamic_cast<ModulePass *>(P);
738 if (!MP)
739 return false;
740
Devang Patel3c8eb622006-11-07 22:56:50 +0000741 // If this pass does not preserve anlysis that is used by other passes
742 // managed by this manager than it is not a suiable pass for this manager.
Devang Pateld65e9e92006-11-08 01:31:28 +0000743 if (!manageablePass(P))
Devang Patel3c8eb622006-11-07 22:56:50 +0000744 return false;
745
Devang Patel8cad70d2006-11-11 01:51:02 +0000746 addPassToManager(MP);
Devang Patel05e1a972006-11-07 22:03:15 +0000747 activeFunctionPassManager = NULL;
748 return true;
749}
750
751
752/// Execute all of the passes scheduled for execution by invoking
753/// runOnModule method. Keep track of whether any of the passes modifies
754/// the module, and if so, return true.
755bool
756ModulePassManager_New::runOnModule(Module &M) {
757 bool Changed = false;
Devang Patela6b6dcb2006-12-07 18:41:09 +0000758 initializeAnalysisInfo();
Devang Patel050ec722006-11-14 01:23:29 +0000759
Devang Patel8cad70d2006-11-11 01:51:02 +0000760 for (std::vector<Pass *>::iterator itr = passVectorBegin(),
761 e = passVectorEnd(); itr != e; ++itr) {
Devang Patel05e1a972006-11-07 22:03:15 +0000762 Pass *P = *itr;
Devang Patel050ec722006-11-14 01:23:29 +0000763
Devang Patele9976aa2006-12-07 19:33:53 +0000764 recordAvailableAnalysis(P);
Devang Patel05e1a972006-11-07 22:03:15 +0000765 ModulePass *MP = dynamic_cast<ModulePass*>(P);
766 Changed |= MP->runOnModule(M);
Devang Patel050ec722006-11-14 01:23:29 +0000767 removeNotPreservedAnalysis(P);
Devang Patelca189262006-11-14 03:05:08 +0000768 removeDeadPasses(P);
Devang Patel05e1a972006-11-07 22:03:15 +0000769 }
770 return Changed;
771}
772
Devang Patelebba9702006-11-13 22:40:09 +0000773/// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000774Pass *ModulePassManager_New::getAnalysisPassFromManager(AnalysisID AID) {
Devang Patelebba9702006-11-13 22:40:09 +0000775
Devang Patel3f0832a2006-11-14 02:54:23 +0000776
777 Pass *P = getAnalysisPass(AID);
778 if (P)
779 return P;
Devang Patelebba9702006-11-13 22:40:09 +0000780
781 if (activeFunctionPassManager &&
Devang Patelf60b5d92006-11-14 01:59:59 +0000782 activeFunctionPassManager->getAnalysisPass(AID) != 0)
Devang Patel3f0832a2006-11-14 02:54:23 +0000783 return activeFunctionPassManager->getAnalysisPass(AID);
Devang Patelebba9702006-11-13 22:40:09 +0000784
785 // TODO : Check inactive managers
Devang Patel3f0832a2006-11-14 02:54:23 +0000786 return NULL;
Devang Patelebba9702006-11-13 22:40:09 +0000787}
788
Devang Patela1514cb2006-12-07 19:39:39 +0000789//===----------------------------------------------------------------------===//
790// PassManagerImpl implementation
791
Devang Patelebba9702006-11-13 22:40:09 +0000792/// Return true IFF AnalysisID AID is currently available.
Devang Patel3f0832a2006-11-14 02:54:23 +0000793Pass *PassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) {
Devang Patelebba9702006-11-13 22:40:09 +0000794
Devang Patel3f0832a2006-11-14 02:54:23 +0000795 Pass *P = NULL;
Devang Patel70868442006-11-13 22:53:19 +0000796 for (std::vector<ModulePassManager_New *>::iterator itr = PassManagers.begin(),
Devang Patel3f0832a2006-11-14 02:54:23 +0000797 e = PassManagers.end(); !P && itr != e; ++itr)
798 P = (*itr)->getAnalysisPassFromManager(AID);
799 return P;
Devang Patelebba9702006-11-13 22:40:09 +0000800}
801
Devang Patel1a6eaa42006-11-11 02:22:31 +0000802/// Schedule pass P for execution. Make sure that passes required by
803/// P are run before P is run. Update analysis info maintained by
804/// the manager. Remove dead passes. This is a recursive function.
805void PassManagerImpl_New::schedulePass(Pass *P) {
806
807 AnalysisUsage AnUsage;
808 P->getAnalysisUsage(AnUsage);
809 const std::vector<AnalysisID> &RequiredSet = AnUsage.getRequiredSet();
810 for (std::vector<AnalysisID>::const_iterator I = RequiredSet.begin(),
811 E = RequiredSet.end(); I != E; ++I) {
812
Devang Patel3f0832a2006-11-14 02:54:23 +0000813 Pass *AnalysisPass = getAnalysisPassFromManager(*I);
814 if (!AnalysisPass) {
Devang Patel1a6eaa42006-11-11 02:22:31 +0000815 // Schedule this analysis run first.
Devang Patel3f0832a2006-11-14 02:54:23 +0000816 AnalysisPass = (*I)->createPass();
817 schedulePass(AnalysisPass);
Devang Patel1a6eaa42006-11-11 02:22:31 +0000818 }
Devang Patel3f0832a2006-11-14 02:54:23 +0000819 setLastUser (AnalysisPass, P);
Devang Patel4a3fa4f2006-11-15 01:48:14 +0000820
821 // Prolong live range of analyses that are needed after an analysis pass
822 // is destroyed, for querying by subsequent passes
823 const std::vector<AnalysisID> &IDs = AnUsage.getRequiredTransitiveSet();
824 for (std::vector<AnalysisID>::const_iterator I = IDs.begin(),
825 E = IDs.end(); I != E; ++I) {
826 Pass *AP = getAnalysisPassFromManager(*I);
827 assert (AP && "Analysis pass is not available");
828 setLastUser(AP, P);
829 }
Devang Patel1a6eaa42006-11-11 02:22:31 +0000830 }
Devang Patel1a6eaa42006-11-11 02:22:31 +0000831 addPass(P);
Devang Patel1a6eaa42006-11-11 02:22:31 +0000832}
833
Devang Patelc290c8a2006-11-07 22:23:34 +0000834/// Schedule all passes from the queue by adding them in their
835/// respective manager's queue.
Devang Patel1a6eaa42006-11-11 02:22:31 +0000836void PassManagerImpl_New::schedulePasses() {
837 for (std::vector<Pass *>::iterator I = passVectorBegin(),
838 E = passVectorEnd(); I != E; ++I)
839 schedulePass (*I);
Devang Patelc290c8a2006-11-07 22:23:34 +0000840}
841
842/// Add pass P to the queue of passes to run.
Devang Patel1a6eaa42006-11-11 02:22:31 +0000843void PassManagerImpl_New::add(Pass *P) {
844 // Do not process Analysis now. Analysis is process while scheduling
845 // the pass vector.
Devang Pateldb789fb2006-11-11 02:06:21 +0000846 addPassToManager(P, false);
Devang Patelc290c8a2006-11-07 22:23:34 +0000847}
848
849// PassManager_New implementation
850/// Add P into active pass manager or use new module pass manager to
851/// manage it.
Devang Patel1a6eaa42006-11-11 02:22:31 +0000852bool PassManagerImpl_New::addPass(Pass *P) {
Devang Patelc290c8a2006-11-07 22:23:34 +0000853
Devang Patel6c9f5482006-11-11 00:42:16 +0000854 if (!activeManager || !activeManager->addPass(P)) {
Devang Patelc290c8a2006-11-07 22:23:34 +0000855 activeManager = new ModulePassManager_New();
856 PassManagers.push_back(activeManager);
857 }
858
859 return activeManager->addPass(P);
860}
861
862/// run - Execute all of the passes scheduled for execution. Keep track of
863/// whether any of the passes modifies the module, and if so, return true.
Devang Patel1a6eaa42006-11-11 02:22:31 +0000864bool PassManagerImpl_New::run(Module &M) {
Devang Patelc290c8a2006-11-07 22:23:34 +0000865
866 schedulePasses();
867 bool Changed = false;
868 for (std::vector<ModulePassManager_New *>::iterator itr = PassManagers.begin(),
869 e = PassManagers.end(); itr != e; ++itr) {
870 ModulePassManager_New *pm = *itr;
871 Changed |= pm->runOnModule(M);
872 }
873 return Changed;
874}
Devang Patel376fefa2006-11-08 10:29:57 +0000875
Devang Patela1514cb2006-12-07 19:39:39 +0000876//===----------------------------------------------------------------------===//
877// PassManager implementation
878
Devang Patel376fefa2006-11-08 10:29:57 +0000879/// Create new pass manager
880PassManager_New::PassManager_New() {
881 PM = new PassManagerImpl_New();
882}
883
884/// add - Add a pass to the queue of passes to run. This passes ownership of
885/// the Pass to the PassManager. When the PassManager is destroyed, the pass
886/// will be destroyed as well, so there is no need to delete the pass. This
887/// implies that all passes MUST be allocated with 'new'.
888void
889PassManager_New::add(Pass *P) {
890 PM->add(P);
891}
892
893/// run - Execute all of the passes scheduled for execution. Keep track of
894/// whether any of the passes modifies the module, and if so, return true.
895bool
896PassManager_New::run(Module &M) {
897 return PM->run(M);
898}
899