LLVM 20.0.0git
Modules | Classes | Functions

// endgoup LLVMCLTO More...

Collaboration diagram for ThinLTO:

Modules

 ThinLTO Cache Control
 // endgoup LLVMCTLTO
 

Classes

struct  LTOObjectBuffer
 Type to wrap a single object returned by ThinLTO. More...
 

Functions

thinlto_code_gen_t thinlto_create_codegen (void)
 Instantiates a ThinLTO code generator.
 
void thinlto_codegen_dispose (thinlto_code_gen_t cg)
 Frees the generator and all memory it internally allocated.
 
void thinlto_codegen_add_module (thinlto_code_gen_t cg, const char *identifier, const char *data, int length)
 Add a module to a ThinLTO code generator.
 
void thinlto_codegen_process (thinlto_code_gen_t cg)
 Optimize and codegen all the modules added to the codegenerator using ThinLTO.
 
unsigned int thinlto_module_get_num_objects (thinlto_code_gen_t cg)
 Returns the number of object files produced by the ThinLTO CodeGenerator.
 
LTOObjectBuffer thinlto_module_get_object (thinlto_code_gen_t cg, unsigned int index)
 Returns a reference to the ith object file produced by the ThinLTO CodeGenerator.
 
unsigned int thinlto_module_get_num_object_files (thinlto_code_gen_t cg)
 Returns the number of object files produced by the ThinLTO CodeGenerator.
 
const charthinlto_module_get_object_file (thinlto_code_gen_t cg, unsigned int index)
 Returns the path to the ith object file produced by the ThinLTO CodeGenerator.
 
lto_bool_t thinlto_codegen_set_pic_model (thinlto_code_gen_t cg, lto_codegen_model)
 Sets which PIC code model to generate.
 
void thinlto_codegen_set_savetemps_dir (thinlto_code_gen_t cg, const char *save_temps_dir)
 Sets the path to a directory to use as a storage for temporary bitcode files.
 
void thinlto_set_generated_objects_dir (thinlto_code_gen_t cg, const char *save_temps_dir)
 Set the path to a directory where to save generated object files.
 
void thinlto_codegen_set_cpu (thinlto_code_gen_t cg, const char *cpu)
 Sets the cpu to generate code for.
 
void thinlto_codegen_disable_codegen (thinlto_code_gen_t cg, lto_bool_t disable)
 Disable CodeGen, only run the stages till codegen and stop.
 
void thinlto_codegen_set_codegen_only (thinlto_code_gen_t cg, lto_bool_t codegen_only)
 Perform CodeGen only: disable all other stages.
 
void thinlto_debug_options (const char *const *options, int number)
 Parse -mllvm style debug options.
 
lto_bool_t lto_module_is_thinlto (lto_module_t mod)
 Test if a module has support for ThinLTO linking.
 
void thinlto_codegen_add_must_preserve_symbol (thinlto_code_gen_t cg, const char *name, int length)
 Adds a symbol to the list of global symbols that must exist in the final generated code.
 
void thinlto_codegen_add_cross_referenced_symbol (thinlto_code_gen_t cg, const char *name, int length)
 Adds a symbol to the list of global symbols that are cross-referenced between ThinLTO files.
 

Detailed Description

// endgoup LLVMCLTO

Function Documentation

◆ lto_module_is_thinlto()

lto_bool_t lto_module_is_thinlto ( lto_module_t  mod)

Test if a module has support for ThinLTO linking.

Since
LTO_API_VERSION=18

◆ thinlto_codegen_add_cross_referenced_symbol()

void thinlto_codegen_add_cross_referenced_symbol ( thinlto_code_gen_t  cg,
const char name,
int  length 
)

Adds a symbol to the list of global symbols that are cross-referenced between ThinLTO files.

If the ThinLTO CodeGenerator can ensure that every references from a ThinLTO module to this symbol is optimized away, then the symbol can be discarded.

Since
LTO_API_VERSION=18

◆ thinlto_codegen_add_module()

void thinlto_codegen_add_module ( thinlto_code_gen_t  cg,
const char identifier,
const char data,
int  length 
)

Add a module to a ThinLTO code generator.

Identifier has to be unique among all the modules in a code generator. The data buffer stays owned by the client, and is expected to be available for the entire lifetime of the thinlto_code_gen_t it is added to.

On failure, returns NULL (check lto_get_error_message() for details).

Since
LTO_API_VERSION=18

◆ thinlto_codegen_add_must_preserve_symbol()

void thinlto_codegen_add_must_preserve_symbol ( thinlto_code_gen_t  cg,
const char name,
int  length 
)

Adds a symbol to the list of global symbols that must exist in the final generated code.

If a function is not listed there, it might be inlined into every usage and optimized away. For every single module, the functions referenced from code outside of the ThinLTO modules need to be added here.

Since
LTO_API_VERSION=18

◆ thinlto_codegen_disable_codegen()

void thinlto_codegen_disable_codegen ( thinlto_code_gen_t  cg,
lto_bool_t  disable 
)

Disable CodeGen, only run the stages till codegen and stop.

The output will be bitcode.

Since
LTO_API_VERSION=19

◆ thinlto_codegen_dispose()

void thinlto_codegen_dispose ( thinlto_code_gen_t  cg)

Frees the generator and all memory it internally allocated.

Upon return the thinlto_code_gen_t is no longer valid.

Since
LTO_API_VERSION=18

◆ thinlto_codegen_process()

void thinlto_codegen_process ( thinlto_code_gen_t  cg)

Optimize and codegen all the modules added to the codegenerator using ThinLTO.

Resulting objects are accessible using thinlto_module_get_object().

Since
LTO_API_VERSION=18

◆ thinlto_codegen_set_codegen_only()

void thinlto_codegen_set_codegen_only ( thinlto_code_gen_t  cg,
lto_bool_t  codegen_only 
)

Perform CodeGen only: disable all other stages.

Since
LTO_API_VERSION=19

◆ thinlto_codegen_set_cpu()

void thinlto_codegen_set_cpu ( thinlto_code_gen_t  cg,
const char cpu 
)

Sets the cpu to generate code for.

Since
LTO_API_VERSION=18

◆ thinlto_codegen_set_pic_model()

lto_bool_t thinlto_codegen_set_pic_model ( thinlto_code_gen_t  cg,
lto_codegen_model   
)

Sets which PIC code model to generate.

Returns true on error (check lto_get_error_message() for details).

Since
LTO_API_VERSION=18

◆ thinlto_codegen_set_savetemps_dir()

void thinlto_codegen_set_savetemps_dir ( thinlto_code_gen_t  cg,
const char save_temps_dir 
)

Sets the path to a directory to use as a storage for temporary bitcode files.

The intention is to make the bitcode files available for debugging at various stage of the pipeline.

Since
LTO_API_VERSION=18

◆ thinlto_create_codegen()

thinlto_code_gen_t thinlto_create_codegen ( void  )

Instantiates a ThinLTO code generator.

Returns NULL on error (check lto_get_error_message() for details).

The ThinLTOCodeGenerator is not intended to be reuse for multiple compilation: the model is that the client adds modules to the generator and ask to perform the ThinLTO optimizations / codegen, and finally destroys the codegenerator.

Since
LTO_API_VERSION=18

◆ thinlto_debug_options()

void thinlto_debug_options ( const char *const options,
int  number 
)

Parse -mllvm style debug options.

Since
LTO_API_VERSION=18

◆ thinlto_module_get_num_object_files()

unsigned int thinlto_module_get_num_object_files ( thinlto_code_gen_t  cg)

Returns the number of object files produced by the ThinLTO CodeGenerator.

It usually matches the number of input files, but this is not a guarantee of the API and may change in future implementation, so the client should not assume it.

Since
LTO_API_VERSION=21

◆ thinlto_module_get_num_objects()

unsigned int thinlto_module_get_num_objects ( thinlto_code_gen_t  cg)

Returns the number of object files produced by the ThinLTO CodeGenerator.

It usually matches the number of input files, but this is not a guarantee of the API and may change in future implementation, so the client should not assume it.

Since
LTO_API_VERSION=18

◆ thinlto_module_get_object()

LTOObjectBuffer thinlto_module_get_object ( thinlto_code_gen_t  cg,
unsigned int  index 
)

Returns a reference to the ith object file produced by the ThinLTO CodeGenerator.

Client should use thinlto_module_get_num_objects() to get the number of available objects.

Since
LTO_API_VERSION=18

◆ thinlto_module_get_object_file()

const char * thinlto_module_get_object_file ( thinlto_code_gen_t  cg,
unsigned int  index 
)

Returns the path to the ith object file produced by the ThinLTO CodeGenerator.

Client should use thinlto_module_get_num_object_files() to get the number of available objects.

Since
LTO_API_VERSION=21

◆ thinlto_set_generated_objects_dir()

void thinlto_set_generated_objects_dir ( thinlto_code_gen_t  cg,
const char save_temps_dir 
)

Set the path to a directory where to save generated object files.

This path can be used by a linker to request on-disk files instead of in-memory buffers. When set, results are available through thinlto_module_get_object_file() instead of thinlto_module_get_object().

Since
LTO_API_VERSION=21