blob: e83ac279f838f9c7cd0e75adcc9e8a4dbbef6e42 [file] [log] [blame]
Peter Collingbourne4e380b02013-09-19 22:15:52 +00001//===-- llvm-lto: a simple command-line program to link modules with LTO --===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This program takes in a list of bitcode files, links them, performs link-time
11// optimization, and outputs an object file.
12//
13//===----------------------------------------------------------------------===//
14
Rafael Espindola282a4702013-10-31 20:51:58 +000015#include "llvm/ADT/StringSet.h"
Teresa Johnson91a88bb2015-10-19 14:30:44 +000016#include "llvm/Bitcode/ReaderWriter.h"
Rafael Espindola0b385c72013-09-30 16:39:19 +000017#include "llvm/CodeGen/CommandFlags.h"
Mehdi Amini354f5202015-11-19 05:52:29 +000018#include "llvm/IR/DiagnosticPrinter.h"
Teresa Johnson91a88bb2015-10-19 14:30:44 +000019#include "llvm/IR/LLVMContext.h"
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +000020#include "llvm/LTO/LTOCodeGenerator.h"
21#include "llvm/LTO/LTOModule.h"
Teresa Johnson91a88bb2015-10-19 14:30:44 +000022#include "llvm/Object/FunctionIndexObjectFile.h"
Peter Collingbourne4e380b02013-09-19 22:15:52 +000023#include "llvm/Support/CommandLine.h"
Benjamin Kramerd59664f2014-04-29 23:26:49 +000024#include "llvm/Support/FileSystem.h"
Peter Collingbourne4e380b02013-09-19 22:15:52 +000025#include "llvm/Support/ManagedStatic.h"
26#include "llvm/Support/PrettyStackTrace.h"
27#include "llvm/Support/Signals.h"
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +000028#include "llvm/Support/TargetSelect.h"
Peter Collingbournec269ed52015-08-27 23:37:36 +000029#include "llvm/Support/ToolOutputFile.h"
Chandler Carruth07baed52014-01-13 08:04:33 +000030#include "llvm/Support/raw_ostream.h"
Peter Collingbournec269ed52015-08-27 23:37:36 +000031#include <list>
Peter Collingbourne4e380b02013-09-19 22:15:52 +000032
33using namespace llvm;
34
Peter Collingbourne070843d2015-03-19 22:01:00 +000035static cl::opt<char>
36OptLevel("O",
37 cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
38 "(default = '-O2')"),
39 cl::Prefix,
40 cl::ZeroOrMore,
41 cl::init('2'));
Peter Collingbourne4e380b02013-09-19 22:15:52 +000042
Duncan P. N. Exon Smithcff5fef2015-09-15 23:05:59 +000043static cl::opt<bool> DisableVerify(
44 "disable-verify", cl::init(false),
45 cl::desc("Do not run the verifier during the optimization pipeline"));
46
Rafael Espindola0b385c72013-09-30 16:39:19 +000047static cl::opt<bool>
48DisableInline("disable-inlining", cl::init(false),
49 cl::desc("Do not run the inliner pass"));
50
51static cl::opt<bool>
52DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false),
53 cl::desc("Do not run the GVN load PRE pass"));
54
Duncan P. N. Exon Smith30c92422014-10-01 18:36:03 +000055static cl::opt<bool>
Arnold Schwaighofereb1a38f2014-10-26 21:50:58 +000056DisableLTOVectorization("disable-lto-vectorization", cl::init(false),
57 cl::desc("Do not run loop or slp vectorization during LTO"));
58
59static cl::opt<bool>
Duncan P. N. Exon Smith30c92422014-10-01 18:36:03 +000060UseDiagnosticHandler("use-diagnostic-handler", cl::init(false),
61 cl::desc("Use a diagnostic handler to test the handler interface"));
62
Teresa Johnsonf72278f2015-11-02 18:02:11 +000063static cl::opt<bool>
64 ThinLTO("thinlto", cl::init(false),
65 cl::desc("Only write combined global index for ThinLTO backends"));
Teresa Johnson91a88bb2015-10-19 14:30:44 +000066
Tobias Edler von Koch49c9a6e2015-11-20 00:13:05 +000067static cl::opt<bool>
68SaveModuleFile("save-merged-module", cl::init(false),
69 cl::desc("Write merged LTO module to file before CodeGen"));
70
Rafael Espindola0b385c72013-09-30 16:39:19 +000071static cl::list<std::string>
72InputFilenames(cl::Positional, cl::OneOrMore,
73 cl::desc("<input bitcode files>"));
74
75static cl::opt<std::string>
76OutputFilename("o", cl::init(""),
77 cl::desc("Override output filename"),
78 cl::value_desc("filename"));
Peter Collingbourne4e380b02013-09-19 22:15:52 +000079
Rafael Espindoladafc53d2013-10-02 14:12:56 +000080static cl::list<std::string>
81ExportedSymbols("exported-symbol",
82 cl::desc("Symbol to export from the resulting object file"),
83 cl::ZeroOrMore);
84
Rafael Espindolacda29112013-10-03 18:29:09 +000085static cl::list<std::string>
86DSOSymbols("dso-symbol",
87 cl::desc("Symbol to put in the symtab in the resulting dso"),
88 cl::ZeroOrMore);
Rafael Espindoladafc53d2013-10-02 14:12:56 +000089
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +000090static cl::opt<bool> ListSymbolsOnly(
91 "list-symbols-only", cl::init(false),
92 cl::desc("Instead of running LTO, list the symbols in each IR file"));
93
Manman Ren6487ce92015-02-24 00:45:56 +000094static cl::opt<bool> SetMergedModule(
95 "set-merged-module", cl::init(false),
96 cl::desc("Use the first input module as the merged module"));
97
Peter Collingbournec269ed52015-08-27 23:37:36 +000098static cl::opt<unsigned> Parallelism("j", cl::Prefix, cl::init(1),
99 cl::desc("Number of backend threads"));
100
Tobias Edler von Koch3f4f6f3e2016-01-18 23:35:24 +0000101static cl::opt<bool> RestoreGlobalsLinkage(
102 "restore-linkage", cl::init(false),
103 cl::desc("Restore original linkage of globals prior to CodeGen"));
104
Rafael Espindola282a4702013-10-31 20:51:58 +0000105namespace {
106struct ModuleInfo {
107 std::vector<bool> CanBeHidden;
108};
109}
110
Benjamin Kramerf044d3f2015-03-09 16:23:46 +0000111static void handleDiagnostics(lto_codegen_diagnostic_severity_t Severity,
112 const char *Msg, void *) {
Yunzhong Gaoef436f02015-11-10 18:52:48 +0000113 errs() << "llvm-lto: ";
Duncan P. N. Exon Smith30c92422014-10-01 18:36:03 +0000114 switch (Severity) {
115 case LTO_DS_NOTE:
116 errs() << "note: ";
117 break;
118 case LTO_DS_REMARK:
119 errs() << "remark: ";
120 break;
121 case LTO_DS_ERROR:
122 errs() << "error: ";
123 break;
124 case LTO_DS_WARNING:
125 errs() << "warning: ";
126 break;
127 }
128 errs() << Msg << "\n";
129}
130
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000131static std::string CurrentActivity;
Mehdi Amini354f5202015-11-19 05:52:29 +0000132static void diagnosticHandler(const DiagnosticInfo &DI) {
133 raw_ostream &OS = errs();
134 OS << "llvm-lto: ";
135 switch (DI.getSeverity()) {
136 case DS_Error:
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000137 OS << "error";
Mehdi Amini354f5202015-11-19 05:52:29 +0000138 break;
139 case DS_Warning:
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000140 OS << "warning";
Mehdi Amini354f5202015-11-19 05:52:29 +0000141 break;
142 case DS_Remark:
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000143 OS << "remark";
Mehdi Amini354f5202015-11-19 05:52:29 +0000144 break;
145 case DS_Note:
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000146 OS << "note";
Mehdi Amini354f5202015-11-19 05:52:29 +0000147 break;
148 }
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000149 if (!CurrentActivity.empty())
150 OS << ' ' << CurrentActivity;
151 OS << ": ";
Mehdi Amini354f5202015-11-19 05:52:29 +0000152
153 DiagnosticPrinterRawOStream DP(OS);
154 DI.print(DP);
155 OS << '\n';
156
157 if (DI.getSeverity() == DS_Error)
158 exit(1);
159}
160
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000161static void diagnosticHandlerWithContenxt(const DiagnosticInfo &DI,
162 void *Context) {
163 diagnosticHandler(DI);
164}
165
Rafael Espindola5e128db2015-12-04 00:45:57 +0000166static void error(const Twine &Msg) {
167 errs() << "llvm-lto: " << Msg << '\n';
168 exit(1);
169}
170
171static void error(std::error_code EC, const Twine &Prefix) {
172 if (EC)
173 error(Prefix + ": " + EC.message());
174}
175
176template <typename T>
177static void error(const ErrorOr<T> &V, const Twine &Prefix) {
178 error(V.getError(), Prefix);
179}
180
Benjamin Kramerf044d3f2015-03-09 16:23:46 +0000181static std::unique_ptr<LTOModule>
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000182getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer,
Rafael Espindola5e128db2015-12-04 00:45:57 +0000183 const TargetOptions &Options) {
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000184 ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
185 MemoryBuffer::getFile(Path);
Rafael Espindola5e128db2015-12-04 00:45:57 +0000186 error(BufferOrErr, "error loading file '" + Path + "'");
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000187 Buffer = std::move(BufferOrErr.get());
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000188 CurrentActivity = ("loading file '" + Path + "'").str();
189 ErrorOr<std::unique_ptr<LTOModule>> Ret = LTOModule::createInLocalContext(
190 Buffer->getBufferStart(), Buffer->getBufferSize(), Options, Path);
191 CurrentActivity = "";
192 return std::move(*Ret);
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000193}
194
195/// \brief List symbols in each IR file.
196///
197/// The main point here is to provide lit-testable coverage for the LTOModule
198/// functionality that's exposed by the C API to list symbols. Moreover, this
199/// provides testing coverage for modules that have been created in their own
200/// contexts.
Rafael Espindola5e128db2015-12-04 00:45:57 +0000201static void listSymbols(const TargetOptions &Options) {
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000202 for (auto &Filename : InputFilenames) {
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000203 std::unique_ptr<MemoryBuffer> Buffer;
204 std::unique_ptr<LTOModule> Module =
Rafael Espindola5e128db2015-12-04 00:45:57 +0000205 getLocalLTOModule(Filename, Buffer, Options);
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000206
207 // List the symbols.
208 outs() << Filename << ":\n";
209 for (int I = 0, E = Module->getSymbolCount(); I != E; ++I)
210 outs() << Module->getSymbolName(I) << "\n";
211 }
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000212}
213
Teresa Johnson91a88bb2015-10-19 14:30:44 +0000214/// Create a combined index file from the input IR files and write it.
215///
216/// This is meant to enable testing of ThinLTO combined index generation,
217/// currently available via the gold plugin via -thinlto.
Rafael Espindola5e128db2015-12-04 00:45:57 +0000218static void createCombinedFunctionIndex() {
Teresa Johnson91a88bb2015-10-19 14:30:44 +0000219 FunctionInfoIndex CombinedIndex;
220 uint64_t NextModuleId = 0;
221 for (auto &Filename : InputFilenames) {
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000222 CurrentActivity = "loading file '" + Filename + "'";
Teresa Johnson6290dbc2015-11-21 21:55:48 +0000223 ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
Teresa Johnson6b923162015-11-23 19:19:11 +0000224 llvm::getFunctionIndexForFile(Filename, diagnosticHandler);
Teresa Johnson6290dbc2015-11-21 21:55:48 +0000225 std::unique_ptr<FunctionInfoIndex> Index = std::move(IndexOrErr.get());
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000226 CurrentActivity = "";
Teresa Johnson6290dbc2015-11-21 21:55:48 +0000227 // Skip files without a function summary.
228 if (!Index)
229 continue;
Teresa Johnson91a88bb2015-10-19 14:30:44 +0000230 CombinedIndex.mergeFrom(std::move(Index), ++NextModuleId);
231 }
232 std::error_code EC;
233 assert(!OutputFilename.empty());
234 raw_fd_ostream OS(OutputFilename + ".thinlto.bc", EC,
235 sys::fs::OpenFlags::F_None);
Rafael Espindola5e128db2015-12-04 00:45:57 +0000236 error(EC, "error opening the file '" + OutputFilename + ".thinlto.bc'");
Teresa Johnson3da931f2015-10-19 19:06:06 +0000237 WriteFunctionSummaryToFile(CombinedIndex, OS);
Teresa Johnson91a88bb2015-10-19 14:30:44 +0000238 OS.close();
Teresa Johnson91a88bb2015-10-19 14:30:44 +0000239}
240
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000241int main(int argc, char **argv) {
242 // Print a stack trace if we signal out.
243 sys::PrintStackTraceOnErrorSignal();
244 PrettyStackTraceProgram X(argc, argv);
245
246 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
247 cl::ParseCommandLineOptions(argc, argv, "llvm LTO linker\n");
248
Rafael Espindola5e128db2015-12-04 00:45:57 +0000249 if (OptLevel < '0' || OptLevel > '3')
250 error("optimization level must be between 0 and 3");
Peter Collingbourne070843d2015-03-19 22:01:00 +0000251
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +0000252 // Initialize the configured targets.
253 InitializeAllTargets();
254 InitializeAllTargetMCs();
255 InitializeAllAsmPrinters();
256 InitializeAllAsmParsers();
257
Rafael Espindola0b385c72013-09-30 16:39:19 +0000258 // set up the TargetOptions for the machine
Eli Benderskyf0f21002014-02-19 17:09:35 +0000259 TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Rafael Espindola0b385c72013-09-30 16:39:19 +0000260
Rafael Espindola5e128db2015-12-04 00:45:57 +0000261 if (ListSymbolsOnly) {
262 listSymbols(Options);
263 return 0;
264 }
Duncan P. N. Exon Smithf9abf4f2014-12-17 02:00:38 +0000265
Rafael Espindola5e128db2015-12-04 00:45:57 +0000266 if (ThinLTO) {
267 createCombinedFunctionIndex();
268 return 0;
269 }
Teresa Johnson91a88bb2015-10-19 14:30:44 +0000270
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000271 unsigned BaseArg = 0;
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000272
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000273 LLVMContext Context;
274 Context.setDiagnosticHandler(diagnosticHandlerWithContenxt, nullptr, true);
275
276 LTOCodeGenerator CodeGen(Context);
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000277
Duncan P. N. Exon Smith30c92422014-10-01 18:36:03 +0000278 if (UseDiagnosticHandler)
279 CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr);
280
Peter Collingbourne44ee84e2015-08-21 22:57:17 +0000281 CodeGen.setCodePICModel(RelocModel);
James Molloy951e5292014-04-14 13:54:16 +0000282
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +0000283 CodeGen.setDebugInfo(LTO_DEBUG_MODEL_DWARF);
Rafael Espindola0b385c72013-09-30 16:39:19 +0000284 CodeGen.setTargetOptions(Options);
Tobias Edler von Koch3f4f6f3e2016-01-18 23:35:24 +0000285 CodeGen.setShouldRestoreGlobalsLinkage(RestoreGlobalsLinkage);
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000286
Rafael Espindola282a4702013-10-31 20:51:58 +0000287 llvm::StringSet<llvm::MallocAllocator> DSOSymbolsSet;
288 for (unsigned i = 0; i < DSOSymbols.size(); ++i)
289 DSOSymbolsSet.insert(DSOSymbols[i]);
290
291 std::vector<std::string> KeptDSOSyms;
292
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000293 for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) {
Rafael Espindolaa7612b42015-12-04 16:14:31 +0000294 CurrentActivity = "loading file '" + InputFilenames[i] + "'";
295 ErrorOr<std::unique_ptr<LTOModule>> ModuleOrErr =
296 LTOModule::createFromFile(Context, InputFilenames[i].c_str(), Options);
297 std::unique_ptr<LTOModule> &Module = *ModuleOrErr;
298 CurrentActivity = "";
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000299
Peter Collingbourne552174392015-08-21 19:09:42 +0000300 unsigned NumSyms = Module->getSymbolCount();
301 for (unsigned I = 0; I < NumSyms; ++I) {
302 StringRef Name = Module->getSymbolName(I);
303 if (!DSOSymbolsSet.count(Name))
304 continue;
305 lto_symbol_attributes Attrs = Module->getSymbolAttributes(I);
306 unsigned Scope = Attrs & LTO_SYMBOL_SCOPE_MASK;
307 if (Scope != LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN)
308 KeptDSOSyms.push_back(Name);
309 }
Manman Ren6487ce92015-02-24 00:45:56 +0000310
311 // We use the first input module as the destination module when
312 // SetMergedModule is true.
313 if (SetMergedModule && i == BaseArg) {
314 // Transfer ownership to the code generator.
Peter Collingbourne9c8909d2015-08-24 22:22:53 +0000315 CodeGen.setModule(std::move(Module));
Yunzhong Gao46261a72015-09-11 20:01:53 +0000316 } else if (!CodeGen.addModule(Module.get())) {
317 // Print a message here so that we know addModule() did not abort.
318 errs() << argv[0] << ": error adding file '" << InputFilenames[i] << "'\n";
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000319 return 1;
Yunzhong Gao46261a72015-09-11 20:01:53 +0000320 }
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000321 }
322
Rafael Espindoladafc53d2013-10-02 14:12:56 +0000323 // Add all the exported symbols to the table of symbols to preserve.
324 for (unsigned i = 0; i < ExportedSymbols.size(); ++i)
325 CodeGen.addMustPreserveSymbol(ExportedSymbols[i].c_str());
326
Rafael Espindolacda29112013-10-03 18:29:09 +0000327 // Add all the dso symbols to the table of symbols to expose.
Rafael Espindola282a4702013-10-31 20:51:58 +0000328 for (unsigned i = 0; i < KeptDSOSyms.size(); ++i)
329 CodeGen.addMustPreserveSymbol(KeptDSOSyms[i].c_str());
Rafael Espindolacda29112013-10-03 18:29:09 +0000330
Akira Hatanaka23b5f672015-01-30 01:14:28 +0000331 // Set cpu and attrs strings for the default target/subtarget.
332 CodeGen.setCpu(MCPU.c_str());
333
Peter Collingbourne070843d2015-03-19 22:01:00 +0000334 CodeGen.setOptLevel(OptLevel - '0');
335
Tom Roederfd1bc602014-04-25 21:46:51 +0000336 std::string attrs;
337 for (unsigned i = 0; i < MAttrs.size(); ++i) {
338 if (i > 0)
339 attrs.append(",");
340 attrs.append(MAttrs[i]);
341 }
342
343 if (!attrs.empty())
344 CodeGen.setAttr(attrs.c_str());
345
Tobias Edler von Koch49c9a6e2015-11-20 00:13:05 +0000346 if (FileType.getNumOccurrences())
347 CodeGen.setFileType(FileType);
348
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000349 if (!OutputFilename.empty()) {
Duncan P. N. Exon Smithcff5fef2015-09-15 23:05:59 +0000350 if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
Yunzhong Gao8e348cc2015-11-17 19:48:12 +0000351 DisableLTOVectorization)) {
352 // Diagnostic messages should have been printed by the handler.
353 errs() << argv[0] << ": error optimizing the code\n";
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000354 return 1;
355 }
356
Tobias Edler von Koch49c9a6e2015-11-20 00:13:05 +0000357 if (SaveModuleFile) {
358 std::string ModuleFilename = OutputFilename;
359 ModuleFilename += ".merged.bc";
360 std::string ErrMsg;
361
362 if (!CodeGen.writeMergedModules(ModuleFilename.c_str())) {
363 errs() << argv[0] << ": writing merged module failed.\n";
364 return 1;
365 }
366 }
367
Peter Collingbournec269ed52015-08-27 23:37:36 +0000368 std::list<tool_output_file> OSs;
369 std::vector<raw_pwrite_stream *> OSPtrs;
370 for (unsigned I = 0; I != Parallelism; ++I) {
371 std::string PartFilename = OutputFilename;
372 if (Parallelism != 1)
373 PartFilename += "." + utostr(I);
374 std::error_code EC;
375 OSs.emplace_back(PartFilename, EC, sys::fs::F_None);
376 if (EC) {
377 errs() << argv[0] << ": error opening the file '" << PartFilename
378 << "': " << EC.message() << "\n";
379 return 1;
380 }
381 OSPtrs.push_back(&OSs.back().os());
382 }
383
Yunzhong Gao8e348cc2015-11-17 19:48:12 +0000384 if (!CodeGen.compileOptimized(OSPtrs)) {
385 // Diagnostic messages should have been printed by the handler.
386 errs() << argv[0] << ": error compiling the code\n";
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000387 return 1;
388 }
389
Peter Collingbournec269ed52015-08-27 23:37:36 +0000390 for (tool_output_file &OS : OSs)
391 OS.keep();
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000392 } else {
Peter Collingbournec269ed52015-08-27 23:37:36 +0000393 if (Parallelism != 1) {
394 errs() << argv[0] << ": -j must be specified together with -o\n";
395 return 1;
396 }
397
Tobias Edler von Koch49c9a6e2015-11-20 00:13:05 +0000398 if (SaveModuleFile) {
399 errs() << argv[0] << ": -save-merged-module must be specified with -o\n";
400 return 1;
401 }
402
Craig Toppere6cb63e2014-04-25 04:24:47 +0000403 const char *OutputName = nullptr;
Duncan P. N. Exon Smithcff5fef2015-09-15 23:05:59 +0000404 if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline,
Yunzhong Gao8e348cc2015-11-17 19:48:12 +0000405 DisableGVNLoadPRE, DisableLTOVectorization)) {
406 // Diagnostic messages should have been printed by the handler.
407 errs() << argv[0] << ": error compiling the code\n";
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000408 return 1;
409 }
410
411 outs() << "Wrote native object file '" << OutputName << "'\n";
412 }
413
Peter Collingbourne4e380b02013-09-19 22:15:52 +0000414 return 0;
415}