Chris Lattner | ab16a65 | 2003-10-13 05:33:01 +0000 | [diff] [blame] | 1 | //===- Pass.cpp - LLVM Pass Infrastructure Implementation -----------------===// |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 482202a | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | b1c9317 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 482202a | 2003-10-20 19:43:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 26e4f89 | 2002-01-21 07:37:31 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file implements the LLVM Pass infrastructure. It is primarily |
| 11 | // responsible with ensuring that passes are executed and batched together |
| 12 | // optimally. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Dan Gohman | 643b3a0 | 2008-05-23 20:40:06 +0000 | [diff] [blame] | 16 | #include "llvm/Pass.h" |
Paul Robinson | af4e64d | 2014-02-06 00:07:05 +0000 | [diff] [blame] | 17 | #include "llvm/IR/Function.h" |
Chandler Carruth | b8ddc70 | 2014-01-12 11:10:32 +0000 | [diff] [blame] | 18 | #include "llvm/IR/IRPrintingPasses.h" |
Chandler Carruth | 1b69ed8 | 2014-03-04 12:32:42 +0000 | [diff] [blame] | 19 | #include "llvm/IR/LegacyPassNameParser.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 20 | #include "llvm/PassRegistry.h" |
David Greene | dfe4ad7 | 2010-01-05 01:30:04 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Debug.h" |
Chris Lattner | 1362602 | 2009-08-23 06:03:38 +0000 | [diff] [blame] | 22 | #include "llvm/Support/raw_ostream.h" |
Chris Lattner | 189d19f | 2003-11-21 20:23:48 +0000 | [diff] [blame] | 23 | using namespace llvm; |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 24 | |
Chandler Carruth | e96dd89 | 2014-04-21 22:55:11 +0000 | [diff] [blame^] | 25 | #define DEBUG_TYPE "ir" |
| 26 | |
Chris Lattner | 7e0dbe6 | 2002-05-06 19:31:52 +0000 | [diff] [blame] | 27 | //===----------------------------------------------------------------------===// |
Chris Lattner | cdd09c2 | 2002-01-31 00:45:31 +0000 | [diff] [blame] | 28 | // Pass Implementation |
Chris Lattner | 654b5bc | 2002-01-22 00:17:48 +0000 | [diff] [blame] | 29 | // |
Chris Lattner | cdd09c2 | 2002-01-31 00:45:31 +0000 | [diff] [blame] | 30 | |
Devang Patel | f5a994e | 2006-12-22 22:49:00 +0000 | [diff] [blame] | 31 | // Force out-of-line virtual method. |
Andrew Trick | 808a7a6 | 2012-02-03 05:12:30 +0000 | [diff] [blame] | 32 | Pass::~Pass() { |
| 33 | delete Resolver; |
Devang Patel | 2c1bba0 | 2007-04-26 21:33:42 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | // Force out-of-line virtual method. |
Devang Patel | f5a994e | 2006-12-22 22:49:00 +0000 | [diff] [blame] | 37 | ModulePass::~ModulePass() { } |
Chris Lattner | 26e4f89 | 2002-01-21 07:37:31 +0000 | [diff] [blame] | 38 | |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 39 | Pass *ModulePass::createPrinterPass(raw_ostream &O, |
| 40 | const std::string &Banner) const { |
Chandler Carruth | 9d80513 | 2014-01-12 11:30:46 +0000 | [diff] [blame] | 41 | return createPrintModulePass(O, Banner); |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 42 | } |
| 43 | |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 44 | PassManagerType ModulePass::getPotentialPassManagerType() const { |
| 45 | return PMT_ModulePassManager; |
| 46 | } |
| 47 | |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 48 | bool Pass::mustPreserveAnalysisID(char &AID) const { |
Craig Topper | c620761 | 2014-04-09 06:08:46 +0000 | [diff] [blame] | 49 | return Resolver->getAnalysisIfAvailable(&AID, true) != nullptr; |
Chris Lattner | 9ad7757 | 2003-03-21 21:41:02 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Joe Abbey | 96e89f6 | 2011-11-21 04:42:21 +0000 | [diff] [blame] | 52 | // dumpPassStructure - Implement the -debug-pass=Structure option |
Dan Gohman | f71c521 | 2010-08-19 01:29:07 +0000 | [diff] [blame] | 53 | void Pass::dumpPassStructure(unsigned Offset) { |
David Greene | dfe4ad7 | 2010-01-05 01:30:04 +0000 | [diff] [blame] | 54 | dbgs().indent(Offset*2) << getPassName() << "\n"; |
Chris Lattner | 198cf42 | 2002-07-30 16:27:02 +0000 | [diff] [blame] | 55 | } |
Chris Lattner | 37104aa | 2002-04-29 14:57:45 +0000 | [diff] [blame] | 56 | |
Dan Gohman | 94f57c5 | 2008-03-14 18:27:04 +0000 | [diff] [blame] | 57 | /// getPassName - Return a nice clean name for a pass. This usually |
| 58 | /// implemented in terms of the name that is registered by one of the |
| 59 | /// Registration templates, but can be overloaded directly. |
| 60 | /// |
Chris Lattner | 071577d | 2002-07-29 21:02:31 +0000 | [diff] [blame] | 61 | const char *Pass::getPassName() const { |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 62 | AnalysisID AID = getPassID(); |
| 63 | const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(AID); |
| 64 | if (PI) |
Chris Lattner | 071577d | 2002-07-29 21:02:31 +0000 | [diff] [blame] | 65 | return PI->getPassName(); |
Chris Lattner | 9afb8e4 | 2007-10-18 16:11:18 +0000 | [diff] [blame] | 66 | return "Unnamed pass: implement Pass::getPassName()"; |
Chris Lattner | 071577d | 2002-07-29 21:02:31 +0000 | [diff] [blame] | 67 | } |
Chris Lattner | 37104aa | 2002-04-29 14:57:45 +0000 | [diff] [blame] | 68 | |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 69 | void Pass::preparePassManager(PMStack &) { |
| 70 | // By default, don't do anything. |
| 71 | } |
| 72 | |
| 73 | PassManagerType Pass::getPotentialPassManagerType() const { |
| 74 | // Default implementation. |
Andrew Trick | 808a7a6 | 2012-02-03 05:12:30 +0000 | [diff] [blame] | 75 | return PMT_Unknown; |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | void Pass::getAnalysisUsage(AnalysisUsage &) const { |
| 79 | // By default, no analysis results are used, all are invalidated. |
| 80 | } |
| 81 | |
| 82 | void Pass::releaseMemory() { |
| 83 | // By default, don't do anything. |
| 84 | } |
| 85 | |
| 86 | void Pass::verifyAnalysis() const { |
| 87 | // By default, don't do anything. |
| 88 | } |
| 89 | |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 90 | void *Pass::getAdjustedAnalysisPointer(AnalysisID AID) { |
Dan Gohman | ffdee30 | 2010-06-21 18:46:45 +0000 | [diff] [blame] | 91 | return this; |
| 92 | } |
| 93 | |
| 94 | ImmutablePass *Pass::getAsImmutablePass() { |
Craig Topper | c620761 | 2014-04-09 06:08:46 +0000 | [diff] [blame] | 95 | return nullptr; |
Dan Gohman | ffdee30 | 2010-06-21 18:46:45 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | PMDataManager *Pass::getAsPMDataManager() { |
Craig Topper | c620761 | 2014-04-09 06:08:46 +0000 | [diff] [blame] | 99 | return nullptr; |
Dan Gohman | ffdee30 | 2010-06-21 18:46:45 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | void Pass::setResolver(AnalysisResolver *AR) { |
| 103 | assert(!Resolver && "Resolver is already set"); |
| 104 | Resolver = AR; |
| 105 | } |
| 106 | |
Misha Brukman | 56a8642 | 2003-10-14 21:38:42 +0000 | [diff] [blame] | 107 | // print - Print out the internal state of the pass. This is called by Analyze |
Misha Brukman | 7eb05a1 | 2003-08-18 14:43:39 +0000 | [diff] [blame] | 108 | // to print out the contents of an analysis. Otherwise it is not necessary to |
Chris Lattner | 2675007 | 2002-07-27 01:12:17 +0000 | [diff] [blame] | 109 | // implement this method. |
| 110 | // |
Chris Lattner | 1362602 | 2009-08-23 06:03:38 +0000 | [diff] [blame] | 111 | void Pass::print(raw_ostream &O,const Module*) const { |
Chris Lattner | 2675007 | 2002-07-27 01:12:17 +0000 | [diff] [blame] | 112 | O << "Pass::print not implemented for pass: '" << getPassName() << "'!\n"; |
| 113 | } |
| 114 | |
Bill Wendling | 22e978a | 2006-12-07 20:04:42 +0000 | [diff] [blame] | 115 | // dump - call print(cerr); |
Chris Lattner | 2675007 | 2002-07-27 01:12:17 +0000 | [diff] [blame] | 116 | void Pass::dump() const { |
Craig Topper | c620761 | 2014-04-09 06:08:46 +0000 | [diff] [blame] | 117 | print(dbgs(), nullptr); |
Chris Lattner | 2675007 | 2002-07-27 01:12:17 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Chris Lattner | cdd09c2 | 2002-01-31 00:45:31 +0000 | [diff] [blame] | 120 | //===----------------------------------------------------------------------===// |
Chris Lattner | ee0788d | 2002-09-25 21:59:11 +0000 | [diff] [blame] | 121 | // ImmutablePass Implementation |
| 122 | // |
Devang Patel | f5a994e | 2006-12-22 22:49:00 +0000 | [diff] [blame] | 123 | // Force out-of-line virtual method. |
| 124 | ImmutablePass::~ImmutablePass() { } |
Chris Lattner | ee0788d | 2002-09-25 21:59:11 +0000 | [diff] [blame] | 125 | |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 126 | void ImmutablePass::initializePass() { |
| 127 | // By default, don't do anything. |
| 128 | } |
| 129 | |
Chris Lattner | ee0788d | 2002-09-25 21:59:11 +0000 | [diff] [blame] | 130 | //===----------------------------------------------------------------------===// |
Chris Lattner | c8e6654 | 2002-04-27 06:56:12 +0000 | [diff] [blame] | 131 | // FunctionPass Implementation |
Chris Lattner | 26e4f89 | 2002-01-21 07:37:31 +0000 | [diff] [blame] | 132 | // |
Chris Lattner | cdd09c2 | 2002-01-31 00:45:31 +0000 | [diff] [blame] | 133 | |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 134 | Pass *FunctionPass::createPrinterPass(raw_ostream &O, |
| 135 | const std::string &Banner) const { |
Chandler Carruth | 9d80513 | 2014-01-12 11:30:46 +0000 | [diff] [blame] | 136 | return createPrintFunctionPass(O, Banner); |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 139 | PassManagerType FunctionPass::getPotentialPassManagerType() const { |
| 140 | return PMT_FunctionPassManager; |
| 141 | } |
| 142 | |
Paul Robinson | 0c12b1d2 | 2014-02-26 01:23:26 +0000 | [diff] [blame] | 143 | bool FunctionPass::skipOptnoneFunction(const Function &F) const { |
Paul Robinson | af4e64d | 2014-02-06 00:07:05 +0000 | [diff] [blame] | 144 | if (F.hasFnAttribute(Attribute::OptimizeNone)) { |
| 145 | DEBUG(dbgs() << "Skipping pass '" << getPassName() |
| 146 | << "' on function " << F.getName() << "\n"); |
| 147 | return true; |
| 148 | } |
| 149 | return false; |
| 150 | } |
| 151 | |
Chris Lattner | cdd09c2 | 2002-01-31 00:45:31 +0000 | [diff] [blame] | 152 | //===----------------------------------------------------------------------===// |
| 153 | // BasicBlockPass Implementation |
| 154 | // |
| 155 | |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 156 | Pass *BasicBlockPass::createPrinterPass(raw_ostream &O, |
| 157 | const std::string &Banner) const { |
Chandler Carruth | 9d80513 | 2014-01-12 11:30:46 +0000 | [diff] [blame] | 158 | return createPrintBasicBlockPass(O, Banner); |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 161 | bool BasicBlockPass::doInitialization(Function &) { |
| 162 | // By default, don't do anything. |
| 163 | return false; |
| 164 | } |
| 165 | |
| 166 | bool BasicBlockPass::doFinalization(Function &) { |
| 167 | // By default, don't do anything. |
| 168 | return false; |
| 169 | } |
| 170 | |
Paul Robinson | 0c12b1d2 | 2014-02-26 01:23:26 +0000 | [diff] [blame] | 171 | bool BasicBlockPass::skipOptnoneFunction(const BasicBlock &BB) const { |
| 172 | const Function *F = BB.getParent(); |
Paul Robinson | af4e64d | 2014-02-06 00:07:05 +0000 | [diff] [blame] | 173 | if (F && F->hasFnAttribute(Attribute::OptimizeNone)) { |
| 174 | // Report this only once per function. |
| 175 | if (&BB == &F->getEntryBlock()) |
| 176 | DEBUG(dbgs() << "Skipping pass '" << getPassName() |
| 177 | << "' on function " << F->getName() << "\n"); |
| 178 | return true; |
| 179 | } |
| 180 | return false; |
| 181 | } |
| 182 | |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 183 | PassManagerType BasicBlockPass::getPotentialPassManagerType() const { |
Andrew Trick | 808a7a6 | 2012-02-03 05:12:30 +0000 | [diff] [blame] | 184 | return PMT_BasicBlockPassManager; |
Dan Gohman | 1cfbfc8 | 2009-12-14 19:43:09 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 187 | const PassInfo *Pass::lookupPassInfo(const void *TI) { |
Owen Anderson | 4154061 | 2010-07-20 21:22:24 +0000 | [diff] [blame] | 188 | return PassRegistry::getPassRegistry()->getPassInfo(TI); |
Chris Lattner | 37d3c95 | 2002-07-23 18:08:00 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Owen Anderson | 8178122 | 2010-07-20 08:26:15 +0000 | [diff] [blame] | 191 | const PassInfo *Pass::lookupPassInfo(StringRef Arg) { |
Owen Anderson | 4154061 | 2010-07-20 21:22:24 +0000 | [diff] [blame] | 192 | return PassRegistry::getPassRegistry()->getPassInfo(Arg); |
Dan Gohman | 0998427 | 2009-10-08 17:00:02 +0000 | [diff] [blame] | 193 | } |
| 194 | |
Andrew Trick | c9ce9d2 | 2012-02-15 03:21:47 +0000 | [diff] [blame] | 195 | Pass *Pass::createPass(AnalysisID ID) { |
| 196 | const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(ID); |
Andrew Trick | 3a61b78 | 2012-02-08 21:22:34 +0000 | [diff] [blame] | 197 | if (!PI) |
Craig Topper | c620761 | 2014-04-09 06:08:46 +0000 | [diff] [blame] | 198 | return nullptr; |
Andrew Trick | 3a61b78 | 2012-02-08 21:22:34 +0000 | [diff] [blame] | 199 | return PI->createPass(); |
| 200 | } |
| 201 | |
Owen Anderson | 8178122 | 2010-07-20 08:26:15 +0000 | [diff] [blame] | 202 | Pass *PassInfo::createPass() const { |
Dan Gohman | ffdee30 | 2010-06-21 18:46:45 +0000 | [diff] [blame] | 203 | assert((!isAnalysisGroup() || NormalCtor) && |
| 204 | "No default implementation found for analysis group!"); |
| 205 | assert(NormalCtor && |
| 206 | "Cannot call createPass on PassInfo without default ctor!"); |
| 207 | return NormalCtor(); |
| 208 | } |
| 209 | |
Chris Lattner | 6e041bd | 2002-08-21 22:17:09 +0000 | [diff] [blame] | 210 | //===----------------------------------------------------------------------===// |
| 211 | // Analysis Group Implementation Code |
| 212 | //===----------------------------------------------------------------------===// |
| 213 | |
Chris Lattner | 6e041bd | 2002-08-21 22:17:09 +0000 | [diff] [blame] | 214 | // RegisterAGBase implementation |
| 215 | // |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 216 | RegisterAGBase::RegisterAGBase(const char *Name, const void *InterfaceID, |
| 217 | const void *PassID, bool isDefault) |
Owen Anderson | 845b14e | 2010-07-21 17:52:45 +0000 | [diff] [blame] | 218 | : PassInfo(Name, InterfaceID) { |
| 219 | PassRegistry::getPassRegistry()->registerAnalysisGroup(InterfaceID, PassID, |
| 220 | *this, isDefault); |
Chris Lattner | 6e041bd | 2002-08-21 22:17:09 +0000 | [diff] [blame] | 221 | } |
| 222 | |
Chris Lattner | 37d3c95 | 2002-07-23 18:08:00 +0000 | [diff] [blame] | 223 | //===----------------------------------------------------------------------===// |
| 224 | // PassRegistrationListener implementation |
| 225 | // |
| 226 | |
| 227 | // PassRegistrationListener ctor - Add the current object to the list of |
| 228 | // PassRegistrationListeners... |
| 229 | PassRegistrationListener::PassRegistrationListener() { |
Owen Anderson | 7fc9fe7 | 2010-07-20 23:41:56 +0000 | [diff] [blame] | 230 | PassRegistry::getPassRegistry()->addRegistrationListener(this); |
Chris Lattner | 37d3c95 | 2002-07-23 18:08:00 +0000 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | // dtor - Remove object from list of listeners... |
| 234 | PassRegistrationListener::~PassRegistrationListener() { |
Owen Anderson | 7fc9fe7 | 2010-07-20 23:41:56 +0000 | [diff] [blame] | 235 | PassRegistry::getPassRegistry()->removeRegistrationListener(this); |
Chris Lattner | 37d3c95 | 2002-07-23 18:08:00 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | // enumeratePasses - Iterate over the registered passes, calling the |
| 239 | // passEnumerate callback on each PassInfo object. |
| 240 | // |
| 241 | void PassRegistrationListener::enumeratePasses() { |
Owen Anderson | 4154061 | 2010-07-20 21:22:24 +0000 | [diff] [blame] | 242 | PassRegistry::getPassRegistry()->enumerateWith(this); |
Chris Lattner | 37d3c95 | 2002-07-23 18:08:00 +0000 | [diff] [blame] | 243 | } |
Reid Spencer | 8edc8be | 2005-04-25 01:01:35 +0000 | [diff] [blame] | 244 | |
Chris Lattner | 5264fce | 2010-01-22 06:29:25 +0000 | [diff] [blame] | 245 | PassNameParser::~PassNameParser() {} |
| 246 | |
Chris Lattner | 23d5405 | 2006-12-01 22:21:11 +0000 | [diff] [blame] | 247 | //===----------------------------------------------------------------------===// |
| 248 | // AnalysisUsage Class Implementation |
| 249 | // |
| 250 | |
Chris Lattner | 1b368a0 | 2006-12-01 23:27:45 +0000 | [diff] [blame] | 251 | namespace { |
| 252 | struct GetCFGOnlyPasses : public PassRegistrationListener { |
Chris Lattner | cbd160f | 2008-08-08 05:33:04 +0000 | [diff] [blame] | 253 | typedef AnalysisUsage::VectorType VectorType; |
| 254 | VectorType &CFGOnlyList; |
| 255 | GetCFGOnlyPasses(VectorType &L) : CFGOnlyList(L) {} |
Andrew Trick | 808a7a6 | 2012-02-03 05:12:30 +0000 | [diff] [blame] | 256 | |
Craig Topper | f398d7c | 2014-03-05 06:35:38 +0000 | [diff] [blame] | 257 | void passEnumerate(const PassInfo *P) override { |
Chris Lattner | 1b368a0 | 2006-12-01 23:27:45 +0000 | [diff] [blame] | 258 | if (P->isCFGOnlyPass()) |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 259 | CFGOnlyList.push_back(P->getTypeInfo()); |
Chris Lattner | 1b368a0 | 2006-12-01 23:27:45 +0000 | [diff] [blame] | 260 | } |
| 261 | }; |
| 262 | } |
| 263 | |
Sylvestre Ledru | 91ce36c | 2012-09-27 10:14:43 +0000 | [diff] [blame] | 264 | // setPreservesCFG - This function should be called to by the pass, iff they do |
Chris Lattner | 23d5405 | 2006-12-01 22:21:11 +0000 | [diff] [blame] | 265 | // not: |
| 266 | // |
| 267 | // 1. Add or remove basic blocks from the function |
| 268 | // 2. Modify terminator instructions in any way. |
| 269 | // |
| 270 | // This function annotates the AnalysisUsage info object to say that analyses |
| 271 | // that only depend on the CFG are preserved by this pass. |
| 272 | // |
| 273 | void AnalysisUsage::setPreservesCFG() { |
| 274 | // Since this transformation doesn't modify the CFG, it preserves all analyses |
| 275 | // that only depend on the CFG (like dominators, loop info, etc...) |
Chris Lattner | 1b368a0 | 2006-12-01 23:27:45 +0000 | [diff] [blame] | 276 | GetCFGOnlyPasses(Preserved).enumeratePasses(); |
Chris Lattner | 23d5405 | 2006-12-01 22:21:11 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 279 | AnalysisUsage &AnalysisUsage::addPreserved(StringRef Arg) { |
| 280 | const PassInfo *PI = Pass::lookupPassInfo(Arg); |
| 281 | // If the pass exists, preserve it. Otherwise silently do nothing. |
| 282 | if (PI) Preserved.push_back(PI->getTypeInfo()); |
| 283 | return *this; |
| 284 | } |
| 285 | |
| 286 | AnalysisUsage &AnalysisUsage::addRequiredID(const void *ID) { |
Dan Gohman | ffdee30 | 2010-06-21 18:46:45 +0000 | [diff] [blame] | 287 | Required.push_back(ID); |
| 288 | return *this; |
| 289 | } |
Chris Lattner | 23d5405 | 2006-12-01 22:21:11 +0000 | [diff] [blame] | 290 | |
Owen Anderson | a7aed18 | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 291 | AnalysisUsage &AnalysisUsage::addRequiredID(char &ID) { |
| 292 | Required.push_back(&ID); |
| 293 | return *this; |
| 294 | } |
| 295 | |
| 296 | AnalysisUsage &AnalysisUsage::addRequiredTransitiveID(char &ID) { |
| 297 | Required.push_back(&ID); |
| 298 | RequiredTransitive.push_back(&ID); |
Dan Gohman | ffdee30 | 2010-06-21 18:46:45 +0000 | [diff] [blame] | 299 | return *this; |
| 300 | } |