Misha Brukman | e22594f | 2005-04-24 17:36:05 +0000 | [diff] [blame] | 1 | //===- llvm-extract.cpp - LLVM function extraction utility ----------------===// |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 09344dc | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 345353d | 2007-12-29 20:44:31 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 09344dc | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 055de18 | 2002-05-22 20:27:00 +0000 | [diff] [blame] | 9 | // |
| 10 | // This utility changes the input module to only contain a single function, |
| 11 | // which is primarily used for debugging transformations. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/SetVector.h" |
| 16 | #include "llvm/ADT/SmallPtrSet.h" |
Chandler Carruth | b7bdfd6 | 2014-01-13 07:38:24 +0000 | [diff] [blame] | 17 | #include "llvm/Bitcode/BitcodeWriterPass.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 18 | #include "llvm/IR/DataLayout.h" |
Chandler Carruth | b8ddc70 | 2014-01-12 11:10:32 +0000 | [diff] [blame] | 19 | #include "llvm/IR/IRPrintingPasses.h" |
| 20 | #include "llvm/IR/LLVMContext.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 21 | #include "llvm/IR/Module.h" |
Duncan P. N. Exon Smith | c55dee1 | 2015-04-14 18:33:00 +0000 | [diff] [blame] | 22 | #include "llvm/IR/UseListOrder.h" |
Chandler Carruth | e60e57b | 2013-03-26 02:25:37 +0000 | [diff] [blame] | 23 | #include "llvm/IRReader/IRReader.h" |
Chandler Carruth | 30d69c2 | 2015-02-13 10:01:29 +0000 | [diff] [blame] | 24 | #include "llvm/IR/LegacyPassManager.h" |
Reid Spencer | 7c16caa | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 25 | #include "llvm/Support/CommandLine.h" |
Benjamin Kramer | d59664f | 2014-04-29 23:26:49 +0000 | [diff] [blame] | 26 | #include "llvm/Support/FileSystem.h" |
Chris Lattner | 76d4632 | 2006-12-06 01:18:01 +0000 | [diff] [blame] | 27 | #include "llvm/Support/ManagedStatic.h" |
Chris Lattner | e3fc2d1 | 2009-03-06 05:34:10 +0000 | [diff] [blame] | 28 | #include "llvm/Support/PrettyStackTrace.h" |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 29 | #include "llvm/Support/Regex.h" |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 30 | #include "llvm/Support/Signals.h" |
Chandler Carruth | e60e57b | 2013-03-26 02:25:37 +0000 | [diff] [blame] | 31 | #include "llvm/Support/SourceMgr.h" |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 32 | #include "llvm/Support/SystemUtils.h" |
| 33 | #include "llvm/Support/ToolOutputFile.h" |
| 34 | #include "llvm/Transforms/IPO.h" |
Chris Lattner | 055de18 | 2002-05-22 20:27:00 +0000 | [diff] [blame] | 35 | #include <memory> |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 36 | using namespace llvm; |
| 37 | |
Chris Lattner | f5cad15 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 38 | // InputFilename - The filename to read from. |
Chris Lattner | 64a6727 | 2002-07-25 16:31:09 +0000 | [diff] [blame] | 39 | static cl::opt<std::string> |
Gabor Greif | e16561c | 2007-07-05 17:07:56 +0000 | [diff] [blame] | 40 | InputFilename(cl::Positional, cl::desc("<input bitcode file>"), |
Chris Lattner | f5cad15 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 41 | cl::init("-"), cl::value_desc("filename")); |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 42 | |
Chris Lattner | 3b203f5 | 2004-02-18 16:53:59 +0000 | [diff] [blame] | 43 | static cl::opt<std::string> |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 44 | OutputFilename("o", cl::desc("Specify output filename"), |
Chris Lattner | 3b203f5 | 2004-02-18 16:53:59 +0000 | [diff] [blame] | 45 | cl::value_desc("filename"), cl::init("-")); |
| 46 | |
| 47 | static cl::opt<bool> |
Dan Gohman | 61a8796 | 2009-08-25 15:34:52 +0000 | [diff] [blame] | 48 | Force("f", cl::desc("Enable binary output on terminals")); |
Chris Lattner | f5cad15 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 49 | |
Misha Brukman | 2ccac82 | 2004-04-22 23:07:39 +0000 | [diff] [blame] | 50 | static cl::opt<bool> |
Andrew Lenharth | 3f13b66 | 2008-03-07 19:51:57 +0000 | [diff] [blame] | 51 | DeleteFn("delete", cl::desc("Delete specified Globals from Module")); |
Misha Brukman | 2ccac82 | 2004-04-22 23:07:39 +0000 | [diff] [blame] | 52 | |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 53 | // ExtractFuncs - The functions to extract from the module. |
Dan Gohman | f684e45 | 2010-02-10 23:58:53 +0000 | [diff] [blame] | 54 | static cl::list<std::string> |
| 55 | ExtractFuncs("func", cl::desc("Specify function to extract"), |
| 56 | cl::ZeroOrMore, cl::value_desc("function")); |
Chris Lattner | f5cad15 | 2002-07-22 02:10:13 +0000 | [diff] [blame] | 57 | |
Andrew Trick | dc073ad | 2013-09-18 23:31:10 +0000 | [diff] [blame] | 58 | // ExtractRegExpFuncs - The functions, matched via regular expression, to |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 59 | // extract from the module. |
| 60 | static cl::list<std::string> |
| 61 | ExtractRegExpFuncs("rfunc", cl::desc("Specify function(s) to extract using a " |
| 62 | "regular expression"), |
| 63 | cl::ZeroOrMore, cl::value_desc("rfunction")); |
| 64 | |
Rafael Espindola | 7043858a | 2012-10-29 02:23:07 +0000 | [diff] [blame] | 65 | // ExtractAlias - The alias to extract from the module. |
| 66 | static cl::list<std::string> |
| 67 | ExtractAliases("alias", cl::desc("Specify alias to extract"), |
| 68 | cl::ZeroOrMore, cl::value_desc("alias")); |
| 69 | |
| 70 | |
| 71 | // ExtractRegExpAliases - The aliases, matched via regular expression, to |
| 72 | // extract from the module. |
| 73 | static cl::list<std::string> |
| 74 | ExtractRegExpAliases("ralias", cl::desc("Specify alias(es) to extract using a " |
| 75 | "regular expression"), |
| 76 | cl::ZeroOrMore, cl::value_desc("ralias")); |
| 77 | |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 78 | // ExtractGlobals - The globals to extract from the module. |
Dan Gohman | f684e45 | 2010-02-10 23:58:53 +0000 | [diff] [blame] | 79 | static cl::list<std::string> |
| 80 | ExtractGlobals("glob", cl::desc("Specify global to extract"), |
| 81 | cl::ZeroOrMore, cl::value_desc("global")); |
Andrew Lenharth | 3f13b66 | 2008-03-07 19:51:57 +0000 | [diff] [blame] | 82 | |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 83 | // ExtractRegExpGlobals - The globals, matched via regular expression, to |
| 84 | // extract from the module... |
| 85 | static cl::list<std::string> |
| 86 | ExtractRegExpGlobals("rglob", cl::desc("Specify global(s) to extract using a " |
| 87 | "regular expression"), |
| 88 | cl::ZeroOrMore, cl::value_desc("rglobal")); |
| 89 | |
Dan Gohman | e592923 | 2009-09-11 20:46:33 +0000 | [diff] [blame] | 90 | static cl::opt<bool> |
| 91 | OutputAssembly("S", |
| 92 | cl::desc("Write output as LLVM assembly"), cl::Hidden); |
| 93 | |
Chris Lattner | 055de18 | 2002-05-22 20:27:00 +0000 | [diff] [blame] | 94 | int main(int argc, char **argv) { |
Chris Lattner | e3fc2d1 | 2009-03-06 05:34:10 +0000 | [diff] [blame] | 95 | // Print a stack trace if we signal out. |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 96 | sys::PrintStackTraceOnErrorSignal(); |
Chris Lattner | e3fc2d1 | 2009-03-06 05:34:10 +0000 | [diff] [blame] | 97 | PrettyStackTraceProgram X(argc, argv); |
Owen Anderson | 6773d38 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 98 | |
Owen Anderson | 19251ec | 2009-07-15 22:16:10 +0000 | [diff] [blame] | 99 | LLVMContext &Context = getGlobalContext(); |
Chris Lattner | e3fc2d1 | 2009-03-06 05:34:10 +0000 | [diff] [blame] | 100 | llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
Duncan P. N. Exon Smith | c55dee1 | 2015-04-14 18:33:00 +0000 | [diff] [blame] | 101 | |
| 102 | // Turn on -preserve-bc-uselistorder by default, but let the command-line |
| 103 | // override it. |
| 104 | setPreserveBitcodeUseListOrder(true); |
| 105 | |
Chris Lattner | e3fc2d1 | 2009-03-06 05:34:10 +0000 | [diff] [blame] | 106 | cl::ParseCommandLineOptions(argc, argv, "llvm extractor\n"); |
Chris Lattner | 055de18 | 2002-05-22 20:27:00 +0000 | [diff] [blame] | 107 | |
Dan Gohman | bf15459 | 2010-08-25 23:33:07 +0000 | [diff] [blame] | 108 | // Use lazy loading, since we only care about selected global values. |
Dan Gohman | e592923 | 2009-09-11 20:46:33 +0000 | [diff] [blame] | 109 | SMDiagnostic Err; |
Rafael Espindola | d233b06 | 2014-08-26 17:29:46 +0000 | [diff] [blame] | 110 | std::unique_ptr<Module> M = getLazyIRFileModule(InputFilename, Err, Context); |
Dan Gohman | e592923 | 2009-09-11 20:46:33 +0000 | [diff] [blame] | 111 | |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 112 | if (!M.get()) { |
Chris Lattner | a3a0681 | 2011-10-16 04:47:35 +0000 | [diff] [blame] | 113 | Err.print(argv[0], errs()); |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 114 | return 1; |
| 115 | } |
| 116 | |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 117 | // Use SetVector to avoid duplicates. |
| 118 | SetVector<GlobalValue *> GVs; |
Andrew Lenharth | 3f13b66 | 2008-03-07 19:51:57 +0000 | [diff] [blame] | 119 | |
Rafael Espindola | 7043858a | 2012-10-29 02:23:07 +0000 | [diff] [blame] | 120 | // Figure out which aliases we should extract. |
| 121 | for (size_t i = 0, e = ExtractAliases.size(); i != e; ++i) { |
| 122 | GlobalAlias *GA = M->getNamedAlias(ExtractAliases[i]); |
| 123 | if (!GA) { |
| 124 | errs() << argv[0] << ": program doesn't contain alias named '" |
| 125 | << ExtractAliases[i] << "'!\n"; |
| 126 | return 1; |
| 127 | } |
| 128 | GVs.insert(GA); |
| 129 | } |
| 130 | |
| 131 | // Extract aliases via regular expression matching. |
| 132 | for (size_t i = 0, e = ExtractRegExpAliases.size(); i != e; ++i) { |
| 133 | std::string Error; |
| 134 | Regex RegEx(ExtractRegExpAliases[i]); |
| 135 | if (!RegEx.isValid(Error)) { |
| 136 | errs() << argv[0] << ": '" << ExtractRegExpAliases[i] << "' " |
| 137 | "invalid regex: " << Error; |
| 138 | } |
| 139 | bool match = false; |
| 140 | for (Module::alias_iterator GA = M->alias_begin(), E = M->alias_end(); |
| 141 | GA != E; GA++) { |
| 142 | if (RegEx.match(GA->getName())) { |
| 143 | GVs.insert(&*GA); |
| 144 | match = true; |
| 145 | } |
| 146 | } |
| 147 | if (!match) { |
| 148 | errs() << argv[0] << ": program doesn't contain global named '" |
| 149 | << ExtractRegExpAliases[i] << "'!\n"; |
| 150 | return 1; |
| 151 | } |
| 152 | } |
| 153 | |
Dan Gohman | f684e45 | 2010-02-10 23:58:53 +0000 | [diff] [blame] | 154 | // Figure out which globals we should extract. |
| 155 | for (size_t i = 0, e = ExtractGlobals.size(); i != e; ++i) { |
Nick Lewycky | 5079e4d | 2011-12-30 19:17:23 +0000 | [diff] [blame] | 156 | GlobalValue *GV = M->getNamedGlobal(ExtractGlobals[i]); |
Dan Gohman | f684e45 | 2010-02-10 23:58:53 +0000 | [diff] [blame] | 157 | if (!GV) { |
| 158 | errs() << argv[0] << ": program doesn't contain global named '" |
| 159 | << ExtractGlobals[i] << "'!\n"; |
| 160 | return 1; |
| 161 | } |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 162 | GVs.insert(GV); |
| 163 | } |
| 164 | |
| 165 | // Extract globals via regular expression matching. |
| 166 | for (size_t i = 0, e = ExtractRegExpGlobals.size(); i != e; ++i) { |
| 167 | std::string Error; |
| 168 | Regex RegEx(ExtractRegExpGlobals[i]); |
| 169 | if (!RegEx.isValid(Error)) { |
| 170 | errs() << argv[0] << ": '" << ExtractRegExpGlobals[i] << "' " |
| 171 | "invalid regex: " << Error; |
| 172 | } |
| 173 | bool match = false; |
Rafael Espindola | bfe44e1 | 2014-05-08 19:30:17 +0000 | [diff] [blame] | 174 | for (auto &GV : M->globals()) { |
| 175 | if (RegEx.match(GV.getName())) { |
| 176 | GVs.insert(&GV); |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 177 | match = true; |
| 178 | } |
| 179 | } |
| 180 | if (!match) { |
| 181 | errs() << argv[0] << ": program doesn't contain global named '" |
| 182 | << ExtractRegExpGlobals[i] << "'!\n"; |
| 183 | return 1; |
| 184 | } |
Dan Gohman | f684e45 | 2010-02-10 23:58:53 +0000 | [diff] [blame] | 185 | } |
Andrew Lenharth | 3f13b66 | 2008-03-07 19:51:57 +0000 | [diff] [blame] | 186 | |
Dan Gohman | f684e45 | 2010-02-10 23:58:53 +0000 | [diff] [blame] | 187 | // Figure out which functions we should extract. |
| 188 | for (size_t i = 0, e = ExtractFuncs.size(); i != e; ++i) { |
Nick Lewycky | 5079e4d | 2011-12-30 19:17:23 +0000 | [diff] [blame] | 189 | GlobalValue *GV = M->getFunction(ExtractFuncs[i]); |
Dan Gohman | f684e45 | 2010-02-10 23:58:53 +0000 | [diff] [blame] | 190 | if (!GV) { |
| 191 | errs() << argv[0] << ": program doesn't contain function named '" |
| 192 | << ExtractFuncs[i] << "'!\n"; |
| 193 | return 1; |
| 194 | } |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 195 | GVs.insert(GV); |
| 196 | } |
| 197 | // Extract functions via regular expression matching. |
| 198 | for (size_t i = 0, e = ExtractRegExpFuncs.size(); i != e; ++i) { |
| 199 | std::string Error; |
| 200 | StringRef RegExStr = ExtractRegExpFuncs[i]; |
| 201 | Regex RegEx(RegExStr); |
| 202 | if (!RegEx.isValid(Error)) { |
| 203 | errs() << argv[0] << ": '" << ExtractRegExpFuncs[i] << "' " |
| 204 | "invalid regex: " << Error; |
| 205 | } |
| 206 | bool match = false; |
Nick Lewycky | 5079e4d | 2011-12-30 19:17:23 +0000 | [diff] [blame] | 207 | for (Module::iterator F = M->begin(), E = M->end(); F != E; |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 208 | F++) { |
| 209 | if (RegEx.match(F->getName())) { |
| 210 | GVs.insert(&*F); |
| 211 | match = true; |
| 212 | } |
| 213 | } |
| 214 | if (!match) { |
| 215 | errs() << argv[0] << ": program doesn't contain global named '" |
| 216 | << ExtractRegExpFuncs[i] << "'!\n"; |
| 217 | return 1; |
| 218 | } |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 219 | } |
| 220 | |
Dan Gohman | bf15459 | 2010-08-25 23:33:07 +0000 | [diff] [blame] | 221 | // Materialize requisite global values. |
Dan Gohman | 0d2c07c | 2010-09-23 00:33:13 +0000 | [diff] [blame] | 222 | if (!DeleteFn) |
| 223 | for (size_t i = 0, e = GVs.size(); i != e; ++i) { |
| 224 | GlobalValue *GV = GVs[i]; |
Rafael Espindola | 246c4fb | 2014-11-01 16:46:18 +0000 | [diff] [blame] | 225 | if (std::error_code EC = GV->materialize()) { |
| 226 | errs() << argv[0] << ": error reading input: " << EC.message() << "\n"; |
| 227 | return 1; |
Dan Gohman | 0d2c07c | 2010-09-23 00:33:13 +0000 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | else { |
| 231 | // Deleting. Materialize every GV that's *not* in GVs. |
| 232 | SmallPtrSet<GlobalValue *, 8> GVSet(GVs.begin(), GVs.end()); |
Rafael Espindola | bfe44e1 | 2014-05-08 19:30:17 +0000 | [diff] [blame] | 233 | for (auto &G : M->globals()) { |
Rafael Espindola | 246c4fb | 2014-11-01 16:46:18 +0000 | [diff] [blame] | 234 | if (!GVSet.count(&G)) { |
Rafael Espindola | 5a52e6d | 2014-10-24 22:50:48 +0000 | [diff] [blame] | 235 | if (std::error_code EC = G.materialize()) { |
| 236 | errs() << argv[0] << ": error reading input: " << EC.message() |
| 237 | << "\n"; |
Dan Gohman | 0d2c07c | 2010-09-23 00:33:13 +0000 | [diff] [blame] | 238 | return 1; |
| 239 | } |
| 240 | } |
| 241 | } |
Rafael Espindola | bfe44e1 | 2014-05-08 19:30:17 +0000 | [diff] [blame] | 242 | for (auto &F : *M) { |
Rafael Espindola | 246c4fb | 2014-11-01 16:46:18 +0000 | [diff] [blame] | 243 | if (!GVSet.count(&F)) { |
Rafael Espindola | 5a52e6d | 2014-10-24 22:50:48 +0000 | [diff] [blame] | 244 | if (std::error_code EC = F.materialize()) { |
| 245 | errs() << argv[0] << ": error reading input: " << EC.message() |
| 246 | << "\n"; |
Dan Gohman | 0d2c07c | 2010-09-23 00:33:13 +0000 | [diff] [blame] | 247 | return 1; |
| 248 | } |
Dan Gohman | bf15459 | 2010-08-25 23:33:07 +0000 | [diff] [blame] | 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 253 | // In addition to deleting all other functions, we also want to spiff it |
| 254 | // up a little bit. Do this now. |
Chandler Carruth | 30d69c2 | 2015-02-13 10:01:29 +0000 | [diff] [blame] | 255 | legacy::PassManager Passes; |
Andrew Lenharth | 3f13b66 | 2008-03-07 19:51:57 +0000 | [diff] [blame] | 256 | |
Chad Rosier | f0d3786 | 2011-09-16 21:09:17 +0000 | [diff] [blame] | 257 | std::vector<GlobalValue*> Gvs(GVs.begin(), GVs.end()); |
| 258 | |
| 259 | Passes.add(createGVExtractionPass(Gvs, DeleteFn)); |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 260 | if (!DeleteFn) |
| 261 | Passes.add(createGlobalDCEPass()); // Delete unreachable globals |
Devang Patel | 9b2a93a | 2010-07-01 19:58:05 +0000 | [diff] [blame] | 262 | Passes.add(createStripDeadDebugInfoPass()); // Remove dead debug info |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 263 | Passes.add(createStripDeadPrototypesPass()); // Remove dead func decls |
| 264 | |
Rafael Espindola | 3fd1e99 | 2014-08-25 18:16:47 +0000 | [diff] [blame] | 265 | std::error_code EC; |
| 266 | tool_output_file Out(OutputFilename, EC, sys::fs::F_None); |
| 267 | if (EC) { |
| 268 | errs() << EC.message() << '\n'; |
Chris Lattner | abd1736 | 2009-08-23 02:56:05 +0000 | [diff] [blame] | 269 | return 1; |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Dan Gohman | e592923 | 2009-09-11 20:46:33 +0000 | [diff] [blame] | 272 | if (OutputAssembly) |
Chandler Carruth | 9d80513 | 2014-01-12 11:30:46 +0000 | [diff] [blame] | 273 | Passes.add(createPrintModulePass(Out.os())); |
Dan Gohman | a2233f2 | 2010-09-01 14:20:41 +0000 | [diff] [blame] | 274 | else if (Force || !CheckBitcodeOutputToConsole(Out.os(), true)) |
| 275 | Passes.add(createBitcodeWriterPass(Out.os())); |
Dan Gohman | 61a8796 | 2009-08-25 15:34:52 +0000 | [diff] [blame] | 276 | |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 277 | Passes.run(*M.get()); |
| 278 | |
Dan Gohman | 4cc73ba | 2010-08-20 01:12:13 +0000 | [diff] [blame] | 279 | // Declare success. |
| 280 | Out.keep(); |
| 281 | |
Chris Lattner | 2793699 | 2007-05-06 05:13:17 +0000 | [diff] [blame] | 282 | return 0; |
Chris Lattner | 055de18 | 2002-05-22 20:27:00 +0000 | [diff] [blame] | 283 | } |