diff --git a/docs/LinkTimeOptimization.html b/docs/LinkTimeOptimization.html index 83c774d09ba..4bc92b24424 100644 --- a/docs/LinkTimeOptimization.html +++ b/docs/LinkTimeOptimization.html @@ -85,7 +85,7 @@ conservative escape analysis.
+--- a.h --- extern int foo1(void); extern void foo2(void); @@ -129,7 +129,7 @@ int main() { $ llvm-gcc --emit-llvm -c a.c -o a.o # <-- a.o is LLVM bitcode file $ llvm-gcc -c main.c -o main.o # <-- main.o is native object file $ llvm-gcc a.o main.o -o main # <-- standard link command without any modifications -
In this example, the linker recognizes that foo2() is an externally visible symbol defined in LLVM bitcode file. The linker completes its usual symbol resolution @@ -286,26 +286,42 @@ $ llvm-gcc a.o main.o -o main # <-- standard link command without any modific
A non-native object file is handled via an lto_module_t. - The following functions allow the linker to check if a file (on disk - or in a memory buffer) is a file which libLTO can process:
- lto_module_is_object_file(const char*) - lto_module_is_object_file_for_target(const char*, const char*) - lto_module_is_object_file_in_memory(const void*, size_t) - lto_module_is_object_file_in_memory_for_target(const void*, size_t, const char*)- If the object file can be processed by libLTO, the linker creates a - lto_module_t by using one of
- lto_module_create(const char*) - lto_module_create_from_memory(const void*, size_t)- and when done, the handle is released via
- lto_module_dispose(lto_module_t)- The linker can introspect the non-native object file by getting the number - of symbols and getting the name and attributes of each symbol via:
- lto_module_get_num_symbols(lto_module_t) - lto_module_get_symbol_name(lto_module_t, unsigned int) - lto_module_get_symbol_attribute(lto_module_t, unsigned int)- The attributes of a symbol include the alignment, visibility, and kind. - + +
A non-native object file is handled via an lto_module_t. +The following functions allow the linker to check if a file (on disk +or in a memory buffer) is a file which libLTO can process:
+ ++lto_module_is_object_file(const char*) +lto_module_is_object_file_for_target(const char*, const char*) +lto_module_is_object_file_in_memory(const void*, size_t) +lto_module_is_object_file_in_memory_for_target(const void*, size_t, const char*) ++ +
If the object file can be processed by libLTO, the linker creates a +lto_module_t by using one of
+ ++lto_module_create(const char*) +lto_module_create_from_memory(const void*, size_t) ++ +
and when done, the handle is released via
+ ++lto_module_dispose(lto_module_t) ++ +
The linker can introspect the non-native object file by getting the number of +symbols and getting the name and attributes of each symbol via:
+ ++lto_module_get_num_symbols(lto_module_t) +lto_module_get_symbol_name(lto_module_t, unsigned int) +lto_module_get_symbol_attribute(lto_module_t, unsigned int) ++ +
The attributes of a symbol include the alignment, visibility, and kind.
Once the linker has loaded each non-native object files into an - lto_module_t, it can request libLTO to process them all and - generate a native object file. This is done in a couple of steps. - First a code generator is created with:
- lto_codegen_create()- then each non-native object file is added to the code generator with:
- lto_codegen_add_module(lto_code_gen_t, lto_module_t)- The linker then has the option of setting some codegen options. Whether - or not to generate DWARF debug info is set with:
- lto_codegen_set_debug_model(lto_code_gen_t)- Which kind of position independence is set with:
- lto_codegen_set_pic_model(lto_code_gen_t)- And each symbol that is referenced by a native object file or otherwise - must not be optimized away is set with:
- lto_codegen_add_must_preserve_symbol(lto_code_gen_t, const char*)- After all these settings are done, the linker requests that a native - object file be created from the modules with the settings using: - lto_codegen_compile(lto_code_gen_t, size*) - which returns a pointer to a buffer containing the generated native - object file. The linker then parses that and links it with the rest - of the native object files. + +
Once the linker has loaded each non-native object files into an +lto_module_t, it can request libLTO to process them all and +generate a native object file. This is done in a couple of steps. +First, a code generator is created with:
+ +lto_codegen_create()+ +
Then, each non-native object file is added to the code generator with:
+ ++lto_codegen_add_module(lto_code_gen_t, lto_module_t) ++ +
The linker then has the option of setting some codegen options. Whether or +not to generate DWARF debug info is set with:
+ +lto_codegen_set_debug_model(lto_code_gen_t)+ +
Which kind of position independence is set with:
+ +lto_codegen_set_pic_model(lto_code_gen_t)+ +
And each symbol that is referenced by a native object file or otherwise must +not be optimized away is set with:
+ ++lto_codegen_add_must_preserve_symbol(lto_code_gen_t, const char*) ++ +
After all these settings are done, the linker requests that a native object +file be created from the modules with the settings using:
+ +lto_codegen_compile(lto_code_gen_t, size*)+ +
which returns a pointer to a buffer containing the generated native +object file. The linker then parses that and links it with the rest +of the native object files.
+everywhere instead of the + *construct. + * + * Once all docs use...for code regions, this style can be merged with the + * one above, and we can drop the [pre] qualifier. + */ +pre.doc_code, .literal-block { padding: 1em 2em 1em 1em } + .doc_notes { background: #fafafa; border: 1px solid #cecece; padding: 0.1em } @@ -88,5 +97,4 @@ th.layout { border: none; font-weight: bold; font-size: 105%; .title { margin-top: 0 } #contents { display: none } div.contents ul { list-style-type: decimal } -.literal-block { padding: 1em 2em 1em 1em } .toc-backref { color: black; text-decoration: none; }