Devang Patel | 6e5a113 | 2006-11-07 21:31:57 +0000 | [diff] [blame] | 1 | //===- PassManager.cpp - LLVM Pass Infrastructure Implementation ----------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 5 | // This file was developed by Devang Patel and is distributed under |
Devang Patel | 6e5a113 | 2006-11-07 21:31:57 +0000 | [diff] [blame] | 6 | // 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 Patel | 6e5a113 | 2006-11-07 21:31:57 +0000 | [diff] [blame] | 16 | #include "llvm/Module.h" |
| 17 | |
| 18 | using namespace llvm; |
| 19 | |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 20 | namespace llvm { |
| 21 | |
| 22 | /// BasicBlockPassManager_New manages BasicBlockPass. It batches all the |
| 23 | /// pass together and sequence them to process one basic block before |
| 24 | /// processing next basic block. |
| 25 | class BasicBlockPassManager_New : public Pass, |
| 26 | public PassManagerAnalysisHelper { |
| 27 | |
| 28 | public: |
| 29 | BasicBlockPassManager_New() { } |
| 30 | |
| 31 | /// Add a pass into a passmanager queue. |
| 32 | bool addPass(Pass *p); |
| 33 | |
| 34 | /// Execute all of the passes scheduled for execution. Keep track of |
| 35 | /// whether any of the passes modifies the function, and if so, return true. |
| 36 | bool runOnFunction(Function &F); |
| 37 | |
| 38 | private: |
| 39 | // Collection of pass that are managed by this manager |
| 40 | std::vector<Pass *> PassVector; |
| 41 | }; |
| 42 | |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 43 | /// FunctionPassManagerImpl_New manages FunctionPasses and BasicBlockPassManagers. |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 44 | /// It batches all function passes and basic block pass managers together and |
| 45 | /// sequence them to process one function at a time before processing next |
| 46 | /// function. |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 47 | class FunctionPassManagerImpl_New : public Pass, |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 48 | public PassManagerAnalysisHelper { |
| 49 | public: |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 50 | FunctionPassManagerImpl_New(ModuleProvider *P) { /* TODO */ } |
| 51 | FunctionPassManagerImpl_New() { |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 52 | activeBBPassManager = NULL; |
| 53 | } |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 54 | ~FunctionPassManagerImpl_New() { /* TODO */ }; |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 55 | |
| 56 | /// add - Add a pass to the queue of passes to run. This passes |
| 57 | /// ownership of the Pass to the PassManager. When the |
| 58 | /// PassManager_X is destroyed, the pass will be destroyed as well, so |
| 59 | /// there is no need to delete the pass. (TODO delete passes.) |
| 60 | /// This implies that all passes MUST be allocated with 'new'. |
| 61 | void add(Pass *P) { /* TODO*/ } |
| 62 | |
| 63 | /// Add pass into the pass manager queue. |
| 64 | bool addPass(Pass *P); |
| 65 | |
| 66 | /// Execute all of the passes scheduled for execution. Keep |
| 67 | /// track of whether any of the passes modifies the function, and if |
| 68 | /// so, return true. |
| 69 | bool runOnModule(Module &M); |
| 70 | |
| 71 | private: |
| 72 | // Collection of pass that are manged by this manager |
| 73 | std::vector<Pass *> PassVector; |
| 74 | |
| 75 | // Active Pass Managers |
| 76 | BasicBlockPassManager_New *activeBBPassManager; |
| 77 | }; |
| 78 | |
| 79 | /// ModulePassManager_New manages ModulePasses and function pass managers. |
| 80 | /// It batches all Module passes passes and function pass managers together and |
| 81 | /// sequence them to process one module. |
| 82 | class ModulePassManager_New : public Pass, |
| 83 | public PassManagerAnalysisHelper { |
| 84 | |
| 85 | public: |
| 86 | ModulePassManager_New() { activeFunctionPassManager = NULL; } |
| 87 | |
| 88 | /// Add a pass into a passmanager queue. |
| 89 | bool addPass(Pass *p); |
| 90 | |
| 91 | /// run - Execute all of the passes scheduled for execution. Keep track of |
| 92 | /// whether any of the passes modifies the module, and if so, return true. |
| 93 | bool runOnModule(Module &M); |
| 94 | |
| 95 | private: |
| 96 | // Collection of pass that are managed by this manager |
| 97 | std::vector<Pass *> PassVector; |
| 98 | |
| 99 | // Active Pass Manager |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 100 | FunctionPassManagerImpl_New *activeFunctionPassManager; |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
Devang Patel | 376fefa | 2006-11-08 10:29:57 +0000 | [diff] [blame] | 103 | /// PassManager_New manages ModulePassManagers |
| 104 | class PassManagerImpl_New : public Pass, |
| 105 | public PassManagerAnalysisHelper { |
| 106 | |
| 107 | public: |
| 108 | |
| 109 | /// add - Add a pass to the queue of passes to run. This passes ownership of |
| 110 | /// the Pass to the PassManager. When the PassManager is destroyed, the pass |
| 111 | /// will be destroyed as well, so there is no need to delete the pass. This |
| 112 | /// implies that all passes MUST be allocated with 'new'. |
| 113 | void add(Pass *P); |
| 114 | |
| 115 | /// run - Execute all of the passes scheduled for execution. Keep track of |
| 116 | /// whether any of the passes modifies the module, and if so, return true. |
| 117 | bool run(Module &M); |
| 118 | |
| 119 | private: |
| 120 | |
| 121 | /// Add a pass into a passmanager queue. This is used by schedulePasses |
| 122 | bool addPass(Pass *p); |
| 123 | |
| 124 | /// Schedule all passes collected in pass queue using add(). Add all the |
| 125 | /// schedule passes into various manager's queue using addPass(). |
| 126 | void schedulePasses(); |
| 127 | |
| 128 | // Collection of pass managers |
| 129 | std::vector<ModulePassManager_New *> PassManagers; |
| 130 | |
| 131 | // Collection of pass that are not yet scheduled |
| 132 | std::vector<Pass *> PassVector; |
| 133 | |
| 134 | // Active Pass Manager |
| 135 | ModulePassManager_New *activeManager; |
| 136 | }; |
| 137 | |
Devang Patel | ca58e35 | 2006-11-08 10:05:38 +0000 | [diff] [blame] | 138 | } // End of llvm namespace |
| 139 | |
Devang Patel | f68a349 | 2006-11-07 22:35:17 +0000 | [diff] [blame] | 140 | // PassManagerAnalysisHelper implementation |
| 141 | |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 142 | /// Return true IFF pass P's required analysis set does not required new |
Devang Patel | f68a349 | 2006-11-07 22:35:17 +0000 | [diff] [blame] | 143 | /// manager. |
| 144 | bool PassManagerAnalysisHelper::manageablePass(Pass *P) { |
| 145 | |
| 146 | AnalysisUsage AnUsage; |
| 147 | P->getAnalysisUsage(AnUsage); |
| 148 | |
| 149 | // If this pass is not preserving information that is required by the other passes |
| 150 | // managed by this manager then use new manager |
| 151 | // TODO |
| 152 | return true; |
| 153 | } |
| 154 | |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 155 | /// Return true IFF AnalysisID AID is currently available. |
Devang Patel | f68a349 | 2006-11-07 22:35:17 +0000 | [diff] [blame] | 156 | bool PassManagerAnalysisHelper::analysisCurrentlyAvailable(AnalysisID AID) { |
| 157 | |
| 158 | // TODO |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | /// Augment RequiredSet by adding analysis required by pass P. |
| 163 | void PassManagerAnalysisHelper::noteDownRequiredAnalysis(Pass *P) { |
| 164 | |
| 165 | // TODO |
| 166 | } |
| 167 | |
| 168 | /// Remove AnalysisID from the RequiredSet |
| 169 | void PassManagerAnalysisHelper::removeAnalysis(AnalysisID AID) { |
| 170 | |
| 171 | // TODO |
| 172 | } |
| 173 | |
| 174 | /// Remove Analyss not preserved by Pass P |
| 175 | void PassManagerAnalysisHelper::removeNotPreservedAnalysis(Pass *P) { |
| 176 | |
| 177 | // TODO |
| 178 | } |
| 179 | |
Devang Patel | 6e5a113 | 2006-11-07 21:31:57 +0000 | [diff] [blame] | 180 | /// BasicBlockPassManager implementation |
| 181 | |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 182 | /// Add pass P into PassVector and return true. If this pass is not |
| 183 | /// manageable by this manager then return false. |
Devang Patel | 6e5a113 | 2006-11-07 21:31:57 +0000 | [diff] [blame] | 184 | bool |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 185 | BasicBlockPassManager_New::addPass(Pass *P) { |
Devang Patel | 6e5a113 | 2006-11-07 21:31:57 +0000 | [diff] [blame] | 186 | |
| 187 | BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P); |
| 188 | if (!BP) |
| 189 | return false; |
| 190 | |
Devang Patel | 3c8eb62 | 2006-11-07 22:56:50 +0000 | [diff] [blame] | 191 | // If this pass does not preserve anlysis that is used by other passes |
| 192 | // managed by this manager than it is not a suiable pass for this manager. |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 193 | if (!manageablePass(P)) |
Devang Patel | 3c8eb62 | 2006-11-07 22:56:50 +0000 | [diff] [blame] | 194 | return false; |
| 195 | |
| 196 | // Take a note of analysis required by this pass. |
| 197 | noteDownRequiredAnalysis(P); |
Devang Patel | 6e5a113 | 2006-11-07 21:31:57 +0000 | [diff] [blame] | 198 | |
| 199 | // Add pass |
| 200 | PassVector.push_back(BP); |
| 201 | return true; |
| 202 | } |
| 203 | |
| 204 | /// Execute all of the passes scheduled for execution by invoking |
| 205 | /// runOnBasicBlock method. Keep track of whether any of the passes modifies |
| 206 | /// the function, and if so, return true. |
| 207 | bool |
| 208 | BasicBlockPassManager_New::runOnFunction(Function &F) { |
| 209 | |
| 210 | bool Changed = false; |
| 211 | for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) |
| 212 | for (std::vector<Pass *>::iterator itr = PassVector.begin(), |
| 213 | e = PassVector.end(); itr != e; ++itr) { |
| 214 | Pass *P = *itr; |
| 215 | BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P); |
| 216 | Changed |= BP->runOnBasicBlock(*I); |
| 217 | } |
| 218 | return Changed; |
| 219 | } |
| 220 | |
Devang Patel | 0c2012f | 2006-11-07 21:49:50 +0000 | [diff] [blame] | 221 | // FunctionPassManager_New implementation |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 222 | /// Create new Function pass manager |
| 223 | FunctionPassManager_New::FunctionPassManager_New() { |
| 224 | FPM = new FunctionPassManagerImpl_New(); |
| 225 | } |
| 226 | |
| 227 | /// add - Add a pass to the queue of passes to run. This passes |
| 228 | /// ownership of the Pass to the PassManager. When the |
| 229 | /// PassManager_X is destroyed, the pass will be destroyed as well, so |
| 230 | /// there is no need to delete the pass. (TODO delete passes.) |
| 231 | /// This implies that all passes MUST be allocated with 'new'. |
| 232 | void |
| 233 | FunctionPassManager_New::add(Pass *P) { |
| 234 | FPM->add(P); |
| 235 | } |
| 236 | |
| 237 | /// Execute all of the passes scheduled for execution. Keep |
| 238 | /// track of whether any of the passes modifies the function, and if |
| 239 | /// so, return true. |
| 240 | bool |
| 241 | FunctionPassManager_New::runOnModule(Module &M) { |
| 242 | return FPM->runOnModule(M); |
| 243 | } |
| 244 | |
| 245 | // FunctionPassManagerImpl_New implementation |
Devang Patel | 0c2012f | 2006-11-07 21:49:50 +0000 | [diff] [blame] | 246 | |
Devang Patel | 0c2012f | 2006-11-07 21:49:50 +0000 | [diff] [blame] | 247 | // FunctionPassManager |
| 248 | |
| 249 | /// Add pass P into the pass manager queue. If P is a BasicBlockPass then |
| 250 | /// either use it into active basic block pass manager or create new basic |
| 251 | /// block pass manager to handle pass P. |
| 252 | bool |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 253 | FunctionPassManagerImpl_New::addPass(Pass *P) { |
Devang Patel | 0c2012f | 2006-11-07 21:49:50 +0000 | [diff] [blame] | 254 | |
| 255 | // If P is a BasicBlockPass then use BasicBlockPassManager_New. |
| 256 | if (BasicBlockPass *BP = dynamic_cast<BasicBlockPass*>(P)) { |
| 257 | |
| 258 | if (!activeBBPassManager |
| 259 | || !activeBBPassManager->addPass(BP)) { |
| 260 | |
| 261 | activeBBPassManager = new BasicBlockPassManager_New(); |
| 262 | |
| 263 | PassVector.push_back(activeBBPassManager); |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 264 | if (!activeBBPassManager->addPass(BP)) |
| 265 | assert(0 && "Unable to add Pass"); |
Devang Patel | 0c2012f | 2006-11-07 21:49:50 +0000 | [diff] [blame] | 266 | } |
| 267 | return true; |
| 268 | } |
| 269 | |
| 270 | FunctionPass *FP = dynamic_cast<FunctionPass *>(P); |
| 271 | if (!FP) |
| 272 | return false; |
| 273 | |
Devang Patel | 3c8eb62 | 2006-11-07 22:56:50 +0000 | [diff] [blame] | 274 | // If this pass does not preserve anlysis that is used by other passes |
| 275 | // managed by this manager than it is not a suiable pass for this manager. |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 276 | if (!manageablePass(P)) |
Devang Patel | 3c8eb62 | 2006-11-07 22:56:50 +0000 | [diff] [blame] | 277 | return false; |
| 278 | |
| 279 | // Take a note of analysis required by this pass. |
| 280 | noteDownRequiredAnalysis(P); |
Devang Patel | 0c2012f | 2006-11-07 21:49:50 +0000 | [diff] [blame] | 281 | |
| 282 | PassVector.push_back(FP); |
| 283 | activeBBPassManager = NULL; |
| 284 | return true; |
| 285 | } |
| 286 | |
| 287 | /// Execute all of the passes scheduled for execution by invoking |
| 288 | /// runOnFunction method. Keep track of whether any of the passes modifies |
| 289 | /// the function, and if so, return true. |
| 290 | bool |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 291 | FunctionPassManagerImpl_New::runOnModule(Module &M) { |
Devang Patel | 0c2012f | 2006-11-07 21:49:50 +0000 | [diff] [blame] | 292 | |
| 293 | bool Changed = false; |
| 294 | for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) |
| 295 | for (std::vector<Pass *>::iterator itr = PassVector.begin(), |
| 296 | e = PassVector.end(); itr != e; ++itr) { |
| 297 | Pass *P = *itr; |
| 298 | FunctionPass *FP = dynamic_cast<FunctionPass*>(P); |
| 299 | Changed |= FP->runOnFunction(*I); |
| 300 | } |
| 301 | return Changed; |
| 302 | } |
| 303 | |
| 304 | |
Devang Patel | 05e1a97 | 2006-11-07 22:03:15 +0000 | [diff] [blame] | 305 | // ModulePassManager implementation |
| 306 | |
| 307 | /// Add P into pass vector if it is manageble. If P is a FunctionPass |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 308 | /// then use FunctionPassManagerImpl_New to manage it. Return false if P |
Devang Patel | 05e1a97 | 2006-11-07 22:03:15 +0000 | [diff] [blame] | 309 | /// is not manageable by this manager. |
| 310 | bool |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 311 | ModulePassManager_New::addPass(Pass *P) { |
Devang Patel | 05e1a97 | 2006-11-07 22:03:15 +0000 | [diff] [blame] | 312 | |
| 313 | // If P is FunctionPass then use function pass maanager. |
| 314 | if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P)) { |
| 315 | |
| 316 | activeFunctionPassManager = NULL; |
| 317 | |
| 318 | if (!activeFunctionPassManager |
| 319 | || !activeFunctionPassManager->addPass(P)) { |
| 320 | |
Devang Patel | 4e12f86 | 2006-11-08 10:44:40 +0000 | [diff] [blame^] | 321 | activeFunctionPassManager = new FunctionPassManagerImpl_New(); |
Devang Patel | 05e1a97 | 2006-11-07 22:03:15 +0000 | [diff] [blame] | 322 | |
| 323 | PassVector.push_back(activeFunctionPassManager); |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 324 | if (!activeFunctionPassManager->addPass(FP)) |
| 325 | assert(0 && "Unable to add pass"); |
Devang Patel | 05e1a97 | 2006-11-07 22:03:15 +0000 | [diff] [blame] | 326 | } |
| 327 | return true; |
| 328 | } |
| 329 | |
| 330 | ModulePass *MP = dynamic_cast<ModulePass *>(P); |
| 331 | if (!MP) |
| 332 | return false; |
| 333 | |
Devang Patel | 3c8eb62 | 2006-11-07 22:56:50 +0000 | [diff] [blame] | 334 | // If this pass does not preserve anlysis that is used by other passes |
| 335 | // managed by this manager than it is not a suiable pass for this manager. |
Devang Patel | d65e9e9 | 2006-11-08 01:31:28 +0000 | [diff] [blame] | 336 | if (!manageablePass(P)) |
Devang Patel | 3c8eb62 | 2006-11-07 22:56:50 +0000 | [diff] [blame] | 337 | return false; |
| 338 | |
| 339 | // Take a note of analysis required by this pass. |
| 340 | noteDownRequiredAnalysis(P); |
Devang Patel | 05e1a97 | 2006-11-07 22:03:15 +0000 | [diff] [blame] | 341 | |
| 342 | PassVector.push_back(MP); |
| 343 | activeFunctionPassManager = NULL; |
| 344 | return true; |
| 345 | } |
| 346 | |
| 347 | |
| 348 | /// Execute all of the passes scheduled for execution by invoking |
| 349 | /// runOnModule method. Keep track of whether any of the passes modifies |
| 350 | /// the module, and if so, return true. |
| 351 | bool |
| 352 | ModulePassManager_New::runOnModule(Module &M) { |
| 353 | bool Changed = false; |
| 354 | for (std::vector<Pass *>::iterator itr = PassVector.begin(), |
| 355 | e = PassVector.end(); itr != e; ++itr) { |
| 356 | Pass *P = *itr; |
| 357 | ModulePass *MP = dynamic_cast<ModulePass*>(P); |
| 358 | Changed |= MP->runOnModule(M); |
| 359 | } |
| 360 | return Changed; |
| 361 | } |
| 362 | |
Devang Patel | c290c8a | 2006-11-07 22:23:34 +0000 | [diff] [blame] | 363 | /// Schedule all passes from the queue by adding them in their |
| 364 | /// respective manager's queue. |
| 365 | void |
Devang Patel | 376fefa | 2006-11-08 10:29:57 +0000 | [diff] [blame] | 366 | PassManagerImpl_New::schedulePasses() { |
Devang Patel | c290c8a | 2006-11-07 22:23:34 +0000 | [diff] [blame] | 367 | /* TODO */ |
| 368 | } |
| 369 | |
| 370 | /// Add pass P to the queue of passes to run. |
| 371 | void |
Devang Patel | 376fefa | 2006-11-08 10:29:57 +0000 | [diff] [blame] | 372 | PassManagerImpl_New::add(Pass *P) { |
Devang Patel | c290c8a | 2006-11-07 22:23:34 +0000 | [diff] [blame] | 373 | /* TODO */ |
| 374 | } |
| 375 | |
| 376 | // PassManager_New implementation |
| 377 | /// Add P into active pass manager or use new module pass manager to |
| 378 | /// manage it. |
| 379 | bool |
Devang Patel | 376fefa | 2006-11-08 10:29:57 +0000 | [diff] [blame] | 380 | PassManagerImpl_New::addPass(Pass *P) { |
Devang Patel | c290c8a | 2006-11-07 22:23:34 +0000 | [diff] [blame] | 381 | |
| 382 | if (!activeManager) { |
| 383 | activeManager = new ModulePassManager_New(); |
| 384 | PassManagers.push_back(activeManager); |
| 385 | } |
| 386 | |
| 387 | return activeManager->addPass(P); |
| 388 | } |
| 389 | |
| 390 | /// run - Execute all of the passes scheduled for execution. Keep track of |
| 391 | /// whether any of the passes modifies the module, and if so, return true. |
| 392 | bool |
Devang Patel | 376fefa | 2006-11-08 10:29:57 +0000 | [diff] [blame] | 393 | PassManagerImpl_New::run(Module &M) { |
Devang Patel | c290c8a | 2006-11-07 22:23:34 +0000 | [diff] [blame] | 394 | |
| 395 | schedulePasses(); |
| 396 | bool Changed = false; |
| 397 | for (std::vector<ModulePassManager_New *>::iterator itr = PassManagers.begin(), |
| 398 | e = PassManagers.end(); itr != e; ++itr) { |
| 399 | ModulePassManager_New *pm = *itr; |
| 400 | Changed |= pm->runOnModule(M); |
| 401 | } |
| 402 | return Changed; |
| 403 | } |
Devang Patel | 376fefa | 2006-11-08 10:29:57 +0000 | [diff] [blame] | 404 | |
| 405 | /// Create new pass manager |
| 406 | PassManager_New::PassManager_New() { |
| 407 | PM = new PassManagerImpl_New(); |
| 408 | } |
| 409 | |
| 410 | /// add - Add a pass to the queue of passes to run. This passes ownership of |
| 411 | /// the Pass to the PassManager. When the PassManager is destroyed, the pass |
| 412 | /// will be destroyed as well, so there is no need to delete the pass. This |
| 413 | /// implies that all passes MUST be allocated with 'new'. |
| 414 | void |
| 415 | PassManager_New::add(Pass *P) { |
| 416 | PM->add(P); |
| 417 | } |
| 418 | |
| 419 | /// run - Execute all of the passes scheduled for execution. Keep track of |
| 420 | /// whether any of the passes modifies the module, and if so, return true. |
| 421 | bool |
| 422 | PassManager_New::run(Module &M) { |
| 423 | return PM->run(M); |
| 424 | } |
| 425 | |