blob: 142e4307260434f5ecebd6c0e261461e92732899 [file] [log] [blame]
Nick Kledzik07b4a622008-02-26 20:26:43 +00001//===-lto.cpp - LLVM Link Time Optimizer ----------------------------------===//
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.
Bill Wendling36cbf032012-03-30 10:29:38 +00007//
Nick Kledzik07b4a622008-02-26 20:26:43 +00008//===----------------------------------------------------------------------===//
9//
Bill Wendling36cbf032012-03-30 10:29:38 +000010// This file implements the Link Time Optimization library. This library is
Nick Kledzik07b4a622008-02-26 20:26:43 +000011// intended to be used by linker to optimize code at link time.
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm-c/lto.h"
Benjamin Kramer0a446fd2015-03-01 21:28:53 +000016#include "llvm/ADT/STLExtras.h"
Rafael Espindola0b385c72013-09-30 16:39:19 +000017#include "llvm/CodeGen/CommandFlags.h"
Duncan P. N. Exon Smithd34b6132014-12-19 07:19:50 +000018#include "llvm/IR/LLVMContext.h"
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +000019#include "llvm/LTO/LTOCodeGenerator.h"
20#include "llvm/LTO/LTOModule.h"
Alp Tokerac903802014-07-04 00:58:41 +000021#include "llvm/Support/MemoryBuffer.h"
Michael J. Spencer50a20c02015-01-29 17:20:41 +000022#include "llvm/Support/Signals.h"
Rafael Espindola77c50d22014-06-19 19:11:22 +000023#include "llvm/Support/TargetSelect.h"
Nick Kledzik07b4a622008-02-26 20:26:43 +000024
Rafael Espindola0b385c72013-09-30 16:39:19 +000025// extra command-line flags needed for LTOCodeGenerator
Peter Collingbourne070843d2015-03-19 22:01:00 +000026static cl::opt<char>
27OptLevel("O",
28 cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
29 "(default = '-O2')"),
30 cl::Prefix,
31 cl::ZeroOrMore,
32 cl::init('2'));
Rafael Espindola0b385c72013-09-30 16:39:19 +000033
34static cl::opt<bool>
35DisableInline("disable-inlining", cl::init(false),
36 cl::desc("Do not run the inliner pass"));
37
38static cl::opt<bool>
39DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false),
40 cl::desc("Do not run the GVN load PRE pass"));
Nick Kledzik07b4a622008-02-26 20:26:43 +000041
Arnold Schwaighofereb1a38f2014-10-26 21:50:58 +000042static cl::opt<bool>
43DisableLTOVectorization("disable-lto-vectorization", cl::init(false),
44 cl::desc("Do not run loop or slp vectorization during LTO"));
45
Bill Wendling36cbf032012-03-30 10:29:38 +000046// Holds most recent error string.
47// *** Not thread safe ***
Nick Kledzik07b4a622008-02-26 20:26:43 +000048static std::string sLastErrorString;
49
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +000050// Holds the initialization state of the LTO module.
51// *** Not thread safe ***
52static bool initialized = false;
53
Rafael Espindolaefa02d52013-10-02 14:36:23 +000054// Holds the command-line option parsing state of the LTO module.
55static bool parsedOptions = false;
56
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +000057// Initialize the configured targets if they have not been initialized.
58static void lto_initialize() {
59 if (!initialized) {
Michael J. Spencer50a20c02015-01-29 17:20:41 +000060#ifdef LLVM_ON_WIN32
61 // Dialog box on crash disabling doesn't work across DLL boundaries, so do
62 // it here.
63 llvm::sys::DisableSystemDialogsOnCrash();
64#endif
65
Rafael Espindola77c50d22014-06-19 19:11:22 +000066 InitializeAllTargetInfos();
67 InitializeAllTargets();
68 InitializeAllTargetMCs();
69 InitializeAllAsmParsers();
70 InitializeAllAsmPrinters();
71 InitializeAllDisassemblers();
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +000072 initialized = true;
73 }
74}
75
Patrik Hagglund9be9d872014-05-05 12:24:08 +000076DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LTOCodeGenerator, lto_code_gen_t)
77DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LTOModule, lto_module_t)
Rafael Espindola83ceb8e2014-05-03 14:59:52 +000078
Tom Roederfd1bc602014-04-25 21:46:51 +000079// Convert the subtarget features into a string to pass to LTOCodeGenerator.
80static void lto_add_attrs(lto_code_gen_t cg) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +000081 LTOCodeGenerator *CG = unwrap(cg);
Tom Roederfd1bc602014-04-25 21:46:51 +000082 if (MAttrs.size()) {
83 std::string attrs;
84 for (unsigned i = 0; i < MAttrs.size(); ++i) {
85 if (i > 0)
86 attrs.append(",");
87 attrs.append(MAttrs[i]);
88 }
89
Rafael Espindola83ceb8e2014-05-03 14:59:52 +000090 CG->setAttr(attrs.c_str());
Tom Roederfd1bc602014-04-25 21:46:51 +000091 }
Peter Collingbourne070843d2015-03-19 22:01:00 +000092
93 if (OptLevel < '0' || OptLevel > '3')
94 report_fatal_error("Optimization level must be between 0 and 3");
95 CG->setOptLevel(OptLevel - '0');
Tom Roederfd1bc602014-04-25 21:46:51 +000096}
97
Bill Wendling36cbf032012-03-30 10:29:38 +000098extern const char* lto_get_version() {
99 return LTOCodeGenerator::getVersionString();
Nick Kledzik07b4a622008-02-26 20:26:43 +0000100}
101
Bill Wendling36cbf032012-03-30 10:29:38 +0000102const char* lto_get_error_message() {
103 return sLastErrorString.c_str();
Nick Kledzik07b4a622008-02-26 20:26:43 +0000104}
105
Reid Klecknerddac1512013-10-24 22:26:04 +0000106bool lto_module_is_object_file(const char* path) {
Bill Wendling36cbf032012-03-30 10:29:38 +0000107 return LTOModule::isBitcodeFile(path);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000108}
109
Reid Klecknerddac1512013-10-24 22:26:04 +0000110bool lto_module_is_object_file_for_target(const char* path,
Bill Wendling36cbf032012-03-30 10:29:38 +0000111 const char* target_triplet_prefix) {
Rafael Espindolaadf21f22014-07-06 17:43:13 +0000112 ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer = MemoryBuffer::getFile(path);
113 if (!Buffer)
Alp Tokerac903802014-07-04 00:58:41 +0000114 return false;
Rafael Espindolaadf21f22014-07-06 17:43:13 +0000115 return LTOModule::isBitcodeForTarget(Buffer->get(), target_triplet_prefix);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000116}
117
Reid Klecknerddac1512013-10-24 22:26:04 +0000118bool lto_module_is_object_file_in_memory(const void* mem, size_t length) {
Bill Wendling36cbf032012-03-30 10:29:38 +0000119 return LTOModule::isBitcodeFile(mem, length);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000120}
121
Reid Klecknerddac1512013-10-24 22:26:04 +0000122bool
Bill Wendling36cbf032012-03-30 10:29:38 +0000123lto_module_is_object_file_in_memory_for_target(const void* mem,
124 size_t length,
125 const char* target_triplet_prefix) {
Alp Tokerac903802014-07-04 00:58:41 +0000126 std::unique_ptr<MemoryBuffer> buffer(LTOModule::makeBuffer(mem, length));
127 if (!buffer)
128 return false;
129 return LTOModule::isBitcodeForTarget(buffer.get(), target_triplet_prefix);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000130}
131
Bill Wendling36cbf032012-03-30 10:29:38 +0000132lto_module_t lto_module_create(const char* path) {
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +0000133 lto_initialize();
Eli Benderskyf0f21002014-02-19 17:09:35 +0000134 llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Peter Collingbourne63086fe2014-07-03 23:28:00 +0000135 return wrap(LTOModule::createFromFile(path, Options, sLastErrorString));
Nick Kledzik07b4a622008-02-26 20:26:43 +0000136}
137
Bill Wendling36cbf032012-03-30 10:29:38 +0000138lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +0000139 lto_initialize();
Eli Benderskyf0f21002014-02-19 17:09:35 +0000140 llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000141 return wrap(
Peter Collingbourne63086fe2014-07-03 23:28:00 +0000142 LTOModule::createFromOpenFile(fd, path, size, Options, sLastErrorString));
Rafael Espindola56e41f72011-02-08 22:40:47 +0000143}
Nick Kledzik07b4a622008-02-26 20:26:43 +0000144
Rafael Espindolab39c7c72011-03-17 00:36:11 +0000145lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
146 size_t file_size,
147 size_t map_size,
Bill Wendling36cbf032012-03-30 10:29:38 +0000148 off_t offset) {
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +0000149 lto_initialize();
Eli Benderskyf0f21002014-02-19 17:09:35 +0000150 llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Peter Collingbourne63086fe2014-07-03 23:28:00 +0000151 return wrap(LTOModule::createFromOpenFileSlice(fd, path, map_size, offset,
152 Options, sLastErrorString));
Rafael Espindolab39c7c72011-03-17 00:36:11 +0000153}
154
Bill Wendling36cbf032012-03-30 10:29:38 +0000155lto_module_t lto_module_create_from_memory(const void* mem, size_t length) {
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +0000156 lto_initialize();
Eli Benderskyf0f21002014-02-19 17:09:35 +0000157 llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Peter Collingbourne63086fe2014-07-03 23:28:00 +0000158 return wrap(LTOModule::createFromBuffer(mem, length, Options, sLastErrorString));
Nick Kledzik07b4a622008-02-26 20:26:43 +0000159}
160
Manman Ren03456a12014-02-10 23:26:14 +0000161lto_module_t lto_module_create_from_memory_with_path(const void* mem,
162 size_t length,
163 const char *path) {
164 lto_initialize();
Eli Benderskyf0f21002014-02-19 17:09:35 +0000165 llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000166 return wrap(
Peter Collingbourne63086fe2014-07-03 23:28:00 +0000167 LTOModule::createFromBuffer(mem, length, Options, sLastErrorString, path));
Manman Ren03456a12014-02-10 23:26:14 +0000168}
169
Duncan P. N. Exon Smithc5800f62014-11-11 23:19:23 +0000170lto_module_t lto_module_create_in_local_context(const void *mem, size_t length,
171 const char *path) {
172 lto_initialize();
173 llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
174 return wrap(LTOModule::createInLocalContext(mem, length, Options,
175 sLastErrorString, path));
176}
177
178lto_module_t lto_module_create_in_codegen_context(const void *mem,
179 size_t length,
180 const char *path,
181 lto_code_gen_t cg) {
182 lto_initialize();
183 llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
184 return wrap(LTOModule::createInContext(mem, length, Options, sLastErrorString,
185 path, &unwrap(cg)->getContext()));
186}
187
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000188void lto_module_dispose(lto_module_t mod) { delete unwrap(mod); }
Nick Kledzik07b4a622008-02-26 20:26:43 +0000189
Bill Wendling36cbf032012-03-30 10:29:38 +0000190const char* lto_module_get_target_triple(lto_module_t mod) {
Rafael Espindolad749fb52014-07-04 14:19:41 +0000191 return unwrap(mod)->getTargetTriple().c_str();
Nick Kledzik07b4a622008-02-26 20:26:43 +0000192}
193
Bill Wendling36cbf032012-03-30 10:29:38 +0000194void lto_module_set_target_triple(lto_module_t mod, const char *triple) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000195 return unwrap(mod)->setTargetTriple(triple);
Rafael Espindola4ef89f52010-08-09 21:09:46 +0000196}
197
Bill Wendling36cbf032012-03-30 10:29:38 +0000198unsigned int lto_module_get_num_symbols(lto_module_t mod) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000199 return unwrap(mod)->getSymbolCount();
Nick Kledzik07b4a622008-02-26 20:26:43 +0000200}
201
Bill Wendling36cbf032012-03-30 10:29:38 +0000202const char* lto_module_get_symbol_name(lto_module_t mod, unsigned int index) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000203 return unwrap(mod)->getSymbolName(index);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000204}
205
Bill Wendling36cbf032012-03-30 10:29:38 +0000206lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
207 unsigned int index) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000208 return unwrap(mod)->getSymbolAttributes(index);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000209}
210
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000211unsigned int lto_module_get_num_deplibs(lto_module_t mod) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000212 return unwrap(mod)->getDependentLibraryCount();
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000213}
214
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000215const char* lto_module_get_deplib(lto_module_t mod, unsigned int index) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000216 return unwrap(mod)->getDependentLibrary(index);
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000217}
218
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000219unsigned int lto_module_get_num_linkeropts(lto_module_t mod) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000220 return unwrap(mod)->getLinkerOptCount();
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000221}
222
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000223const char* lto_module_get_linkeropt(lto_module_t mod, unsigned int index) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000224 return unwrap(mod)->getLinkerOpt(index);
Yunzhong Gaoa88d7ab2014-01-21 18:31:27 +0000225}
226
Quentin Colombet5fa1f6f2014-01-15 22:04:35 +0000227void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg,
228 lto_diagnostic_handler_t diag_handler,
229 void *ctxt) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000230 unwrap(cg)->setDiagnosticHandler(diag_handler, ctxt);
Quentin Colombet5fa1f6f2014-01-15 22:04:35 +0000231}
232
Duncan P. N. Exon Smithd34b6132014-12-19 07:19:50 +0000233static lto_code_gen_t createCodeGen(bool InLocalContext) {
Peter Collingbourne4ccf0f12013-09-24 23:52:22 +0000234 lto_initialize();
Rafael Espindola0b385c72013-09-30 16:39:19 +0000235
Eli Benderskyf0f21002014-02-19 17:09:35 +0000236 TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Rafael Espindola0b385c72013-09-30 16:39:19 +0000237
Duncan P. N. Exon Smithd34b6132014-12-19 07:19:50 +0000238 LTOCodeGenerator *CodeGen =
239 InLocalContext ? new LTOCodeGenerator(make_unique<LLVMContext>())
240 : new LTOCodeGenerator();
Rafael Espindola0b385c72013-09-30 16:39:19 +0000241 if (CodeGen)
242 CodeGen->setTargetOptions(Options);
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000243 return wrap(CodeGen);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000244}
245
Duncan P. N. Exon Smithd34b6132014-12-19 07:19:50 +0000246lto_code_gen_t lto_codegen_create(void) {
247 return createCodeGen(/* InLocalContext */ false);
248}
249
250lto_code_gen_t lto_codegen_create_in_local_context(void) {
251 return createCodeGen(/* InLocalContext */ true);
252}
253
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000254void lto_codegen_dispose(lto_code_gen_t cg) { delete unwrap(cg); }
Nick Kledzik07b4a622008-02-26 20:26:43 +0000255
Reid Klecknerddac1512013-10-24 22:26:04 +0000256bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
Rafael Espindolad12b4a32014-10-25 04:06:10 +0000257 return !unwrap(cg)->addModule(unwrap(mod));
Nick Kledzik07b4a622008-02-26 20:26:43 +0000258}
259
Manman Ren6487ce92015-02-24 00:45:56 +0000260void lto_codegen_set_module(lto_code_gen_t cg, lto_module_t mod) {
261 unwrap(cg)->setModule(unwrap(mod));
262}
263
Reid Klecknerddac1512013-10-24 22:26:04 +0000264bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000265 unwrap(cg)->setDebugInfo(debug);
Shuxin Yangb6696a92013-08-07 05:19:23 +0000266 return false;
Nick Kledzik07b4a622008-02-26 20:26:43 +0000267}
268
Reid Klecknerddac1512013-10-24 22:26:04 +0000269bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000270 unwrap(cg)->setCodePICModel(model);
Shuxin Yangb6696a92013-08-07 05:19:23 +0000271 return false;
Nick Kledzik07b4a622008-02-26 20:26:43 +0000272}
273
Bill Wendling152e4732012-03-31 10:44:20 +0000274void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000275 return unwrap(cg)->setCpu(cpu);
Rafael Espindolaccab1dd2010-08-11 00:15:13 +0000276}
277
Bill Wendling36cbf032012-03-30 10:29:38 +0000278void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path) {
Rafael Espindolafac373c2011-02-24 21:04:06 +0000279 // In here only for backwards compatibility. We use MC now.
Nick Kledzikcac8c8a2009-06-04 00:28:45 +0000280}
281
Bill Wendling152e4732012-03-31 10:44:20 +0000282void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
Bill Wendling36cbf032012-03-30 10:29:38 +0000283 int nargs) {
Rafael Espindolafac373c2011-02-24 21:04:06 +0000284 // In here only for backwards compatibility. We use MC now.
Rafael Espindola00456462010-08-10 18:55:09 +0000285}
286
Bill Wendling36cbf032012-03-30 10:29:38 +0000287void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg,
Bill Wendling152e4732012-03-31 10:44:20 +0000288 const char *symbol) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000289 unwrap(cg)->addMustPreserveSymbol(symbol);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000290}
291
Peter Collingbourne070843d2015-03-19 22:01:00 +0000292static void maybeParseOptions() {
Rafael Espindolaefa02d52013-10-02 14:36:23 +0000293 if (!parsedOptions) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000294 unwrap(cg)->parseCodeGenDebugOptions();
Tom Roederfd1bc602014-04-25 21:46:51 +0000295 lto_add_attrs(cg);
Rafael Espindolaefa02d52013-10-02 14:36:23 +0000296 parsedOptions = true;
297 }
Peter Collingbourne070843d2015-03-19 22:01:00 +0000298}
299
300bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
301 maybeParseOptions();
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000302 return !unwrap(cg)->writeMergedModules(path, sLastErrorString);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000303}
304
Bill Wendling152e4732012-03-31 10:44:20 +0000305const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
Peter Collingbourne070843d2015-03-19 22:01:00 +0000306 maybeParseOptions();
307 return unwrap(cg)->compile(length, DisableInline,
Arnold Schwaighofereb1a38f2014-10-26 21:50:58 +0000308 DisableGVNLoadPRE, DisableLTOVectorization,
309 sLastErrorString);
Nick Kledzik07b4a622008-02-26 20:26:43 +0000310}
311
Manman Ren8121e1d2015-02-03 18:39:15 +0000312bool lto_codegen_optimize(lto_code_gen_t cg) {
Peter Collingbourne070843d2015-03-19 22:01:00 +0000313 maybeParseOptions();
314 return !unwrap(cg)->optimize(DisableInline,
Manman Ren8121e1d2015-02-03 18:39:15 +0000315 DisableGVNLoadPRE, DisableLTOVectorization,
316 sLastErrorString);
317}
318
319const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
Peter Collingbourne070843d2015-03-19 22:01:00 +0000320 maybeParseOptions();
Manman Ren8121e1d2015-02-03 18:39:15 +0000321 return unwrap(cg)->compileOptimized(length, sLastErrorString);
322}
323
Reid Klecknerddac1512013-10-24 22:26:04 +0000324bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
Peter Collingbourne070843d2015-03-19 22:01:00 +0000325 maybeParseOptions();
Arnold Schwaighofereb1a38f2014-10-26 21:50:58 +0000326 return !unwrap(cg)->compile_to_file(
Peter Collingbourne070843d2015-03-19 22:01:00 +0000327 name, DisableInline, DisableGVNLoadPRE,
Arnold Schwaighofereb1a38f2014-10-26 21:50:58 +0000328 DisableLTOVectorization, sLastErrorString);
Rafael Espindola26b57ff2011-03-22 20:57:13 +0000329}
330
Bill Wendling152e4732012-03-31 10:44:20 +0000331void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {
Rafael Espindola83ceb8e2014-05-03 14:59:52 +0000332 unwrap(cg)->setCodeGenDebugOptions(opt);
Duncan Sands31554ab2009-07-03 15:38:01 +0000333}
Rafael Espindolaa5ef4902015-02-03 19:25:53 +0000334
335unsigned int lto_api_version() { return LTO_API_VERSION; }