1 /*===-- llvm-c/lto.h - LTO Public C Interface ---------------------*- C -*-===*\
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 header provides public interface to an abstract link time optimization*|
11 |* library.  LLVM provides an implementation of this interface for use with   *|
12 |* llvm bitcode files.                                                        *|
13 |*                                                                            *|
14 \*===----------------------------------------------------------------------===*/
15 
16 module llvm.c.lto;
17 
18 import core.stdc.stddef;
19 import core.sys.posix.unistd;
20 
21 extern(C) nothrow:
22 
23 alias lto_bool_t = bool;
24 
25 /**
26  * @defgroup LLVMCLTO LTO
27  * @ingroup LLVMC
28  *
29  * @{
30  */
31 
32 enum LTO_API_VERSION = 19;
33 
34 /**
35  * \since prior to LTO_API_VERSION=3
36  */
37 enum lto_symbol_attributes {
38     ALIGNMENT_MASK              = 0x0000001F, /* log2 of alignment */
39     PERMISSIONS_MASK            = 0x000000E0,
40     PERMISSIONS_CODE            = 0x000000A0,
41     PERMISSIONS_DATA            = 0x000000C0,
42     PERMISSIONS_RODATA          = 0x00000080,
43     DEFINITION_MASK             = 0x00000700,
44     DEFINITION_REGULAR          = 0x00000100,
45     DEFINITION_TENTATIVE        = 0x00000200,
46     DEFINITION_WEAK             = 0x00000300,
47     DEFINITION_UNDEFINED        = 0x00000400,
48     DEFINITION_WEAKUNDEF        = 0x00000500,
49     SCOPE_MASK                  = 0x00003800,
50     SCOPE_INTERNAL              = 0x00000800,
51     SCOPE_HIDDEN                = 0x00001000,
52     SCOPE_PROTECTED             = 0x00002000,
53     SCOPE_DEFAULT               = 0x00001800,
54     SCOPE_DEFAULT_CAN_BE_HIDDEN = 0x00002800,
55     COMDAT                      = 0x00004000,
56     ALIAS                       = 0x00008000,
57 }
58 
59 /**
60  * \since prior to LTO_API_VERSION=3
61  */
62 enum lto_debug_model {
63     MODEL_NONE         = 0,
64     MODEL_DWARF        = 1,
65 }
66 
67 /**
68  * \since prior to LTO_API_VERSION=3
69  */
70 enum lto_codegen_model {
71     STATIC         = 0,
72     DYNAMIC        = 1,
73     DYNAMIC_NO_PIC = 2,
74     DEFAULT        = 3,
75 }
76 
77 
78 /** opaque reference to a loaded object module */
79 struct LLVMOpaqueLTOModule {};
80 alias lto_module_t = LLVMOpaqueLTOModule*;
81 
82 /** opaque reference to a code generator */
83 struct LLVMOpaqueLTOCodeGenerator {};
84 alias lto_code_gen_t = LLVMOpaqueLTOCodeGenerator*;
85 
86 /** opaque reference to a thin code generator */
87 struct LLVMOpaqueThinLTOCodeGenerator {};
88 alias thinlto_code_gen_t = LLVMOpaqueThinLTOCodeGenerator*;
89 
90 /**
91  * Returns a printable string.
92  *
93  * \since prior to LTO_API_VERSION=3
94  */
95 extern const(char)*
96 lto_get_version();
97 
98 /**
99  * Returns the last error string or NULL if last operation was successful.
100  *
101  * \since prior to LTO_API_VERSION=3
102  */
103 extern const(char)*
104 lto_get_error_message();
105 
106 /**
107  * Checks if a file is a loadable object file.
108  *
109  * \since prior to LTO_API_VERSION=3
110  */
111 extern bool
112 lto_module_is_object_file(const(char)* path);
113 
114 /**
115  * Checks if a file is a loadable object compiled for requested target.
116  *
117  * \since prior to LTO_API_VERSION=3
118  */
119 extern bool
120 lto_module_is_object_file_for_target(const(char)* path,
121                                      const(char)* target_triple_prefix);
122 
123 /**
124  * Checks if a buffer is a loadable object file.
125  *
126  * \since prior to LTO_API_VERSION=3
127  */
128 extern lto_bool_t
129 lto_module_is_object_file_in_memory(const(void)* mem, size_t length);
130 
131 /**
132  * Checks if a buffer is a loadable object file.
133  *
134  * \since prior to LTO_API_VERSION=3
135  */
136 extern lto_bool_t lto_module_is_object_file_in_memory(const(void)* mem,
137                                                       size_t length);
138 
139 /**
140  * Checks if a buffer is a loadable object compiled for requested target.
141  *
142  * \since prior to LTO_API_VERSION=3
143  */
144 extern lto_bool_t
145 lto_module_is_object_file_in_memory_for_target(const(void)* mem, size_t length,
146                                               const(char)* target_triple_prefix);
147 
148 /**
149  * Loads an object file from disk.
150  * Returns NULL on error (check lto_get_error_message() for details).
151  *
152  * \since prior to LTO_API_VERSION=3
153  */
154 extern lto_module_t
155 lto_module_create(const(char)* path);
156 
157 /**
158  * Loads an object file from memory.
159  * Returns NULL on error (check lto_get_error_message() for details).
160  *
161  * \since prior to LTO_API_VERSION=3
162  */
163 extern lto_module_t
164 lto_module_create_from_memory(const(void)* mem, size_t length);
165 
166 /**
167  * Loads an object file from memory with an extra path argument.
168  * Returns NULL on error (check lto_get_error_message() for details).
169  *
170  * \since LTO_API_VERSION=9
171  */
172 extern lto_module_t
173 lto_module_create_from_memory_with_path(const(void)* mem, size_t length,
174                                         const(char)* path);
175 
176 /**
177  * \brief Loads an object file in its own context.
178  *
179  * Loads an object file in its own LLVMContext.  This function call is
180  * thread-safe.  However, modules created this way should not be merged into an
181  * lto_code_gen_t using \a lto_codegen_add_module().
182  *
183  * Returns NULL on error (check lto_get_error_message() for details).
184  *
185  * \since LTO_API_VERSION=11
186  */
187 extern lto_module_t
188 lto_module_create_in_local_context(const(void)* mem, size_t length,
189                                    const(char)* path);
190 
191 /**
192  * \brief Loads an object file in the codegen context.
193  *
194  * Loads an object file into the same context as \c cg.  The module is safe to
195  * add using \a lto_codegen_add_module().
196  *
197  * Returns NULL on error (check lto_get_error_message() for details).
198  *
199  * \since LTO_API_VERSION=11
200  */
201 extern lto_module_t
202 lto_module_create_in_codegen_context(const(void)* mem, size_t length,
203                                      const(char)* path, lto_code_gen_t cg);
204 
205 /**
206  * Loads an object file from disk. The seek point of fd is not preserved.
207  * Returns NULL on error (check lto_get_error_message() for details).
208  *
209  * \since LTO_API_VERSION=5
210  */
211 extern lto_module_t
212 lto_module_create_from_fd(int fd, const(char)* path, size_t file_size);
213 
214 /**
215  * Loads an object file from disk. The seek point of fd is not preserved.
216  * Returns NULL on error (check lto_get_error_message() for details).
217  *
218  * \since LTO_API_VERSION=5
219  */
220 extern lto_module_t
221 lto_module_create_from_fd_at_offset(int fd, const(char)* path, size_t file_size,
222                                     size_t map_size, off_t offset);
223 
224 /**
225  * Frees all memory internally allocated by the module.
226  * Upon return the lto_module_t is no longer valid.
227  *
228  * \since prior to LTO_API_VERSION=3
229  */
230 extern void
231 lto_module_dispose(lto_module_t mod);
232 
233 /**
234  * Returns triple string which the object module was compiled under.
235  *
236  * \since prior to LTO_API_VERSION=3
237  */
238 extern const(char)*
239 lto_module_get_target_triple(lto_module_t mod);
240 
241 /**
242  * Sets triple string with which the object will be codegened.
243  *
244  * \since LTO_API_VERSION=4
245  */
246 extern void
247 lto_module_set_target_triple(lto_module_t mod, const(char) *triple);
248 
249 /**
250  * Returns the number of symbols in the object module.
251  *
252  * \since prior to LTO_API_VERSION=3
253  */
254 extern uint
255 lto_module_get_num_symbols(lto_module_t mod);
256 
257 /**
258  * Returns the name of the ith symbol in the object module.
259  *
260  * \since prior to LTO_API_VERSION=3
261  */
262 extern const(char)*
263 lto_module_get_symbol_name(lto_module_t mod, uint index);
264 
265 /**
266  * Returns the attributes of the ith symbol in the object module.
267  *
268  * \since prior to LTO_API_VERSION=3
269  */
270 extern lto_symbol_attributes
271 lto_module_get_symbol_attribute(lto_module_t mod, uint index);
272 
273 /**
274  * Returns the module's linker options.
275  *
276  * The linker options may consist of multiple flags. It is the linker's
277  * responsibility to split the flags using a platform-specific mechanism.
278  *
279  * \since LTO_API_VERSION=16
280  */
281 extern const(char)*
282 lto_module_get_linkeropts(lto_module_t mod);
283 
284 /**
285  * Diagnostic severity.
286  *
287  * \since LTO_API_VERSION=7
288  */
289 enum lto_codegen_diagnostic_severity_t {
290   ERROR = 0,
291   WARNING = 1,
292   REMARK = 3, // Added in LTO_API_VERSION=10.
293   NOTE = 2,
294 }
295 
296 /**
297  * Diagnostic handler type.
298  * \p severity defines the severity.
299  * \p diag is the actual diagnostic.
300  * The diagnostic is not prefixed by any of severity keyword, e.g., 'error: '.
301  * \p ctxt is used to pass the context set with the diagnostic handler.
302  *
303  * \since LTO_API_VERSION=7
304  */
305 typedef void (*lto_diagnostic_handler_t)(
306     lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt);
307 
308 /**
309  * Set a diagnostic handler and the related context (void *).
310  * This is more general than lto_get_error_message, as the diagnostic handler
311  * can be called at anytime within lto.
312  *
313  * \since LTO_API_VERSION=7
314  */
315 extern void lto_codegen_set_diagnostic_handler(lto_code_gen_t,
316                                                lto_diagnostic_handler_t,
317                                                void *);
318 
319 /**
320  * Instantiates a code generator.
321  * Returns NULL on error (check lto_get_error_message() for details).
322  *
323  * All modules added using \a lto_codegen_add_module() must have been created
324  * in the same context as the codegen.
325  *
326  * \since prior to LTO_API_VERSION=3
327  */
328 extern lto_code_gen_t
329 lto_codegen_create();
330 
331 /**
332  * \brief Instantiate a code generator in its own context.
333  *
334  * Instantiates a code generator in its own context.  Modules added via \a
335  * lto_codegen_add_module() must have all been created in the same context,
336  * using \a lto_module_create_in_codegen_context().
337  *
338  * \since LTO_API_VERSION=11
339  */
340 extern lto_code_gen_t
341 lto_codegen_create_in_local_context();
342 
343 /**
344  * Frees all code generator and all memory it internally allocated.
345  * Upon return the lto_code_gen_t is no longer valid.
346  *
347  * \since prior to LTO_API_VERSION=3
348  */
349 extern void
350 lto_codegen_dispose(lto_code_gen_t);
351 
352 /**
353  * Add an object module to the set of modules for which code will be generated.
354  * Returns true on error (check lto_get_error_message() for details).
355  *
356  * \c cg and \c mod must both be in the same context.  See \a
357  * lto_codegen_create_in_local_context() and \a
358  * lto_module_create_in_codegen_context().
359  *
360  * \since prior to LTO_API_VERSION=3
361  */
362 extern lto_bool_t
363 lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod);
364 
365 /**
366  * Sets the object module for code generation. This will transfer the ownership
367  * of the module to the code generator.
368  *
369  * \c cg and \c mod must both be in the same context.
370  *
371  * \since LTO_API_VERSION=13
372  */
373 extern void
374 lto_codegen_set_module(lto_code_gen_t cg, lto_module_t mod);
375 
376 /**
377  * Sets if debug info should be generated.
378  * Returns true on error (check lto_get_error_message() for details).
379  *
380  * \since prior to LTO_API_VERSION=3
381  */
382 extern lto_bool_t
383 lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model);
384 
385 /**
386  * Sets which PIC code model to generated.
387  * Returns true on error (check lto_get_error_message() for details).
388  *
389  * \since prior to LTO_API_VERSION=3
390  */
391 extern lto_bool_t
392 lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model);
393 
394 /**
395  * Sets the cpu to generate code for.
396  *
397  * \since LTO_API_VERSION=4
398  */
399 extern void
400 lto_codegen_set_cpu(lto_code_gen_t cg, const(char) *cpu);
401 
402 /**
403  * Sets the location of the assembler tool to run. If not set, libLTO
404  * will use gcc to invoke the assembler.
405  *
406  * \since LTO_API_VERSION=3
407  */
408 extern void
409 lto_codegen_set_assembler_path(lto_code_gen_t cg, const(char)* path);
410 
411 /**
412  * Sets extra arguments that libLTO should pass to the assembler.
413  *
414  * \since LTO_API_VERSION=4
415  */
416 extern void
417 lto_codegen_set_assembler_args(lto_code_gen_t cg, const(char)** args,
418                                int nargs);
419 
420 /**
421  * Adds to a list of all global symbols that must exist in the final generated
422  * code. If a function is not listed there, it might be inlined into every usage
423  * and optimized away.
424  *
425  * \since prior to LTO_API_VERSION=3
426  */
427 extern void
428 lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const(char)* symbol);
429 
430 /**
431  * Writes a new object file at the specified path that contains the
432  * merged contents of all modules added so far.
433  * Returns true on error (check lto_get_error_message() for details).
434  *
435  * \since LTO_API_VERSION=5
436  */
437 extern lto_bool_t
438 lto_codegen_write_merged_modules(lto_code_gen_t cg, const(char)* path);
439 
440 /**
441  * Generates code for all added modules into one native object file.
442  * This calls lto_codegen_optimize then lto_codegen_compile_optimized.
443  *
444  * On success returns a pointer to a generated mach-o/ELF buffer and
445  * length set to the buffer size.  The buffer is owned by the
446  * lto_code_gen_t and will be freed when lto_codegen_dispose()
447  * is called, or lto_codegen_compile() is called again.
448  * On failure, returns NULL (check lto_get_error_message() for details).
449  *
450  * \since prior to LTO_API_VERSION=3
451  */
452 extern const(void)*
453 lto_codegen_compile(lto_code_gen_t cg, size_t* length);
454 
455 /**
456  * Generates code for all added modules into one native object file.
457  * This calls lto_codegen_optimize then lto_codegen_compile_optimized (instead
458  * of returning a generated mach-o/ELF buffer, it writes to a file).
459  *
460  * The name of the file is written to name. Returns true on error.
461  *
462  * \since LTO_API_VERSION=5
463  */
464 extern lto_bool_t
465 lto_codegen_compile_to_file(lto_code_gen_t cg, const(char)** name);
466 
467 /**
468  * Runs optimization for the merged module. Returns true on error.
469  *
470  * \since LTO_API_VERSION=12
471  */
472 extern lto_bool_t
473 lto_codegen_optimize(lto_code_gen_t cg);
474 
475 /**
476  * Generates code for the optimized merged module into one native object file.
477  * It will not run any IR optimizations on the merged module.
478  *
479  * On success returns a pointer to a generated mach-o/ELF buffer and length set
480  * to the buffer size.  The buffer is owned by the lto_code_gen_t and will be
481  * freed when lto_codegen_dispose() is called, or
482  * lto_codegen_compile_optimized() is called again. On failure, returns NULL
483  * (check lto_get_error_message() for details).
484  *
485  * \since LTO_API_VERSION=12
486  */
487 extern const(void)*
488 lto_codegen_compile_optimized(lto_code_gen_t cg, size_t* length);
489 
490 /**
491  * Returns the runtime API version.
492  *
493  * \since LTO_API_VERSION=12
494  */
495 extern unsigned int
496 lto_api_version(void);
497 
498 /**
499  * Sets options to help debug codegen bugs.
500  *
501  * \since prior to LTO_API_VERSION=3
502  */
503 extern void
504 lto_codegen_debug_options(lto_code_gen_t cg, const(char)*);
505 
506 /**
507  * Initializes LLVM disassemblers.
508  * FIXME: This doesn't really belong here.
509  *
510  * \since LTO_API_VERSION=5
511  */
512 extern void
513 lto_initialize_disassembler();
514 
515 /**
516  * Sets if we should run internalize pass during optimization and code
517  * generation.
518  *
519  * \since LTO_API_VERSION=14
520  */
521 extern void
522 lto_codegen_set_should_internalize(lto_code_gen_t cg,
523                                    lto_bool_t ShouldInternalize);
524 
525 /**
526  * \brief Set whether to embed uselists in bitcode.
527  *
528  * Sets whether \a lto_codegen_write_merged_modules() should embed uselists in
529  * output bitcode.  This should be turned on for all -save-temps output.
530  *
531  * \since LTO_API_VERSION=15
532  */
533 extern void
534 lto_codegen_set_should_embed_uselists(lto_code_gen_t cg,
535                                       lto_bool_t ShouldEmbedUselists);
536 
537 /**
538  * @}
539  * @defgroup LLVMCTLTO ThinLTO
540  * @ingroup LLVMC
541  *
542  * @{
543  */
544 
545 /**
546  * Type to wrap a single object returned by ThinLTO.
547  *
548  * \since LTO_API_VERSION=18
549  */
550 struct LTOObjectBuffer {
551   const(char)* Buffer;
552   size_t Size;
553 }
554 
555 /**
556  * Instantiates a ThinLTO code generator.
557  * Returns NULL on error (check lto_get_error_message() for details).
558  *
559  *
560  * The ThinLTOCodeGenerator is not intended to be reuse for multiple
561  * compilation: the model is that the client adds modules to the generator and
562  * ask to perform the ThinLTO optimizations / codegen, and finally destroys the
563  * codegenerator.
564  *
565  * \since LTO_API_VERSION=18
566  */
567 extern thinlto_code_gen_t thinlto_create_codegen();
568 
569 /**
570  * Frees the generator and all memory it internally allocated.
571  * Upon return the thinlto_code_gen_t is no longer valid.
572  *
573  * \since LTO_API_VERSION=18
574  */
575 extern void thinlto_codegen_dispose(thinlto_code_gen_t cg);
576 
577 /**
578  * Add a module to a ThinLTO code generator. Identifier has to be unique among
579  * all the modules in a code generator. The data buffer stays owned by the
580  * client, and is expected to be available for the entire lifetime of the
581  * thinlto_code_gen_t it is added to.
582  *
583  * On failure, returns NULL (check lto_get_error_message() for details).
584  *
585  *
586  * \since LTO_API_VERSION=18
587  */
588 extern void thinlto_codegen_add_module(thinlto_code_gen_t cg,
589                                        const(char)* identifier, const(char)* data,
590                                        int length);
591 
592 /**
593  * Optimize and codegen all the modules added to the codegenerator using
594  * ThinLTO. Resulting objects are accessible using thinlto_module_get_object().
595  *
596  * \since LTO_API_VERSION=18
597  */
598 extern void thinlto_codegen_process(thinlto_code_gen_t cg);
599 
600 /**
601  * Returns the number of object files produced by the ThinLTO CodeGenerator.
602  *
603  * It usually matches the number of input files, but this is not a guarantee of
604  * the API and may change in future implementation, so the client should not
605  * assume it.
606  *
607  * \since LTO_API_VERSION=18
608  */
609 extern uint thinlto_module_get_num_objects(thinlto_code_gen_t cg);
610 
611 /**
612  * Returns a reference to the ith object file produced by the ThinLTO
613  * CodeGenerator.
614  *
615  * Client should use \p thinlto_module_get_num_objects() to get the number of
616  * available objects.
617  *
618  * \since LTO_API_VERSION=18
619  */
620 extern LTOObjectBuffer thinlto_module_get_object(thinlto_code_gen_t cg,
621                                                  uint index);
622 
623 /**
624  * Sets which PIC code model to generate.
625  * Returns true on error (check lto_get_error_message() for details).
626  *
627  * \since LTO_API_VERSION=18
628  */
629 extern lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg,
630                                                 lto_codegen_model);
631 
632 /**
633  * @}
634  * @defgroup LLVMCTLTO_CACHING ThinLTO Cache Control
635  * @ingroup LLVMCTLTO
636  *
637  * These entry points control the ThinLTO cache. The cache is intended to
638  * support incremental build, and thus needs to be persistent accross build.
639  * The client enabled the cache by supplying a path to an existing directory.
640  * The code generator will use this to store objects files that may be reused
641  * during a subsequent build.
642  * To avoid filling the disk space, a few knobs are provided:
643  *  - The pruning interval limit the frequency at which the garbage collector
644  *    will try to scan the cache directory to prune it from expired entries.
645  *    Setting to -1 disable the pruning (default).
646  *  - The pruning expiration time indicates to the garbage collector how old an
647  *    entry needs to be to be removed.
648  *  - Finally, the garbage collector can be instructed to prune the cache till
649  *    the occupied space goes below a threshold.
650  * @{
651  */
652 
653 /**
654  * Sets the path to a directory to use as a cache storage for incremental build.
655  * Setting this activates caching.
656  *
657  * \since LTO_API_VERSION=18
658  */
659 extern void thinlto_codegen_set_cache_dir(thinlto_code_gen_t cg,
660                                           const(char)* cache_dir);
661 
662 /**
663  * Sets the cache pruning interval (in seconds). A negative value disable the
664  * pruning. An unspecified default value will be applied, and a value of 0 will
665  * be ignored.
666  *
667  * \since LTO_API_VERSION=18
668  */
669 extern void thinlto_codegen_set_cache_pruning_interval(thinlto_code_gen_t cg,
670                                                        int interval);
671 
672 /**
673  * Sets the maximum cache size that can be persistent across build, in terms of
674  * percentage of the available space on the the disk. Set to 100 to indicate
675  * no limit, 50 to indicate that the cache size will not be left over half the
676  * available space. A value over 100 will be reduced to 100, a value of 0 will
677  * be ignored. An unspecified default value will be applied.
678  *
679  * The formula looks like:
680  *  AvailableSpace = FreeSpace + ExistingCacheSize
681  *  NewCacheSize = AvailableSpace * P/100
682  *
683  * \since LTO_API_VERSION=18
684  */
685 extern void thinlto_codegen_set_final_cache_size_relative_to_available_space(
686     thinlto_code_gen_t cg, uint percentage);
687 
688 /**
689  * Sets the expiration (in seconds) for an entry in the cache. An unspecified
690  * default value will be applied. A value of 0 will be ignored.
691  *
692  * \since LTO_API_VERSION=18
693  */
694 extern void thinlto_codegen_set_cache_entry_expiration(thinlto_code_gen_t cg,
695                                                        uint expiration);
696 
697 /**
698  * @}
699  */
700 
701 /**
702  * Sets the path to a directory to use as a storage for temporary bitcode files.
703  * The intention is to make the bitcode files available for debugging at various
704  * stage of the pipeline.
705  *
706  * \since LTO_API_VERSION=18
707  */
708 extern void thinlto_codegen_set_savetemps_dir(thinlto_code_gen_t cg,
709                                               const(char)* save_temps_dir);
710 
711 /**
712  * Sets the cpu to generate code for.
713  *
714  * \since LTO_API_VERSION=18
715  */
716 extern void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const(char)* cpu);
717 
718 /**
719  * Disable CodeGen, only run the stages till codegen and stop. The output will
720  * be bitcode.
721  *
722  * \since LTO_API_VERSION=19
723  */
724 extern void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg,
725                                             lto_bool_t disable);
726 
727 /**
728  * Perform CodeGen only: disable all other stages.
729  *
730  * \since LTO_API_VERSION=19
731  */
732 extern void thinlto_codegen_set_codegen_only(thinlto_code_gen_t cg,
733                                              lto_bool_t codegen_only);
734 
735 /**
736  * Parse -mllvm style debug options.
737  *
738  * \since LTO_API_VERSION=18
739  */
740 extern void thinlto_debug_options(const(char)** options, int number);
741 
742 /**
743  * Test if a module has support for ThinLTO linking.
744  *
745  * \since LTO_API_VERSION=18
746  */
747 extern lto_bool_t lto_module_is_thinlto(lto_module_t mod);
748 
749 /**
750  * Adds a symbol to the list of global symbols that must exist in the final
751  * generated code. If a function is not listed there, it might be inlined into
752  * every usage and optimized away. For every single module, the functions
753  * referenced from code outside of the ThinLTO modules need to be added here.
754  *
755  * \since LTO_API_VERSION=18
756  */
757 extern void thinlto_codegen_add_must_preserve_symbol(thinlto_code_gen_t cg,
758                                                      const(char)* name,
759                                                      int length);
760 
761 /**
762  * Adds a symbol to the list of global symbols that are cross-referenced between
763  * ThinLTO files. If the ThinLTO CodeGenerator can ensure that every
764  * references from a ThinLTO module to this symbol is optimized away, then
765  * the symbol can be discarded.
766  *
767  * \since LTO_API_VERSION=18
768  */
769 extern void thinlto_codegen_add_cross_referenced_symbol(thinlto_code_gen_t cg,
770                                                         const(char)* name,
771                                                         int length);
772 
773 #ifdef __cplusplus
774 }
775 #endif
776 
777 /**
778  * @}
779  */
780 
781 #endif /* LLVM_C_LTO_H */