diff options
author | Ben Dunbobbin <bd1976llvm@gmail.com> | 2019-06-12 11:07:56 +0000 |
---|---|---|
committer | Ben Dunbobbin <bd1976llvm@gmail.com> | 2019-06-12 11:07:56 +0000 |
commit | 564d248ec2f2a1dc0245ee7942a32fb72e7e1c84 (patch) | |
tree | f776b3fa7eab5f6e645330164488d7a08a61128c /llvm/include/llvm-c | |
parent | f6efac67e18c5ea66305b2cbc561705eab4ee776 (diff) | |
download | bcm5719-llvm-564d248ec2f2a1dc0245ee7942a32fb72e7e1c84.tar.gz bcm5719-llvm-564d248ec2f2a1dc0245ee7942a32fb72e7e1c84.zip |
[ThinLTO]LTO]Legacy] Fix dependent libraries support by adding querying of the IRSymtab
Dependent libraries support for the legacy api was committed in a
broken state (see: https://reviews.llvm.org/D60274). This was missed
due to the painful nature of having to integrate the changes into a
linker in order to test. This change implements support for dependent
libraries in the legacy LTO api:
- I have removed the current api function, which returns a single
string, and added functions to access each dependent library
specifier individually.
- To reduce the testing pain, I have made the api functions as thin as
possible to maximize coverage from llvm-lto.
- When doing ThinLTO the system linker will load the modules lazily
when scanning the input files. Unfortunately, when modules are
lazily loaded there is no access to module level named metadata. To
fix this I have added api functions that allow querying the IRSymtab
for the dependent libraries. I hope to expand the api in the future
so that, eventually, all the information needed by a client linker
during scan can be retrieved from the IRSymtab.
Differential Revision: https://reviews.llvm.org/D62935
llvm-svn: 363140
Diffstat (limited to 'llvm/include/llvm-c')
-rw-r--r-- | llvm/include/llvm-c/lto.h | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h index 5a33898d0f8..2467722b195 100644 --- a/llvm/include/llvm-c/lto.h +++ b/llvm/include/llvm-c/lto.h @@ -298,14 +298,6 @@ extern const char* lto_module_get_linkeropts(lto_module_t mod); /** -* Returns the module's dependent library specifiers. -* -* \since LTO_API_VERSION=24 -*/ -extern const char* -lto_module_get_dependent_libraries(lto_module_t mod); - -/** * Diagnostic severity. * * \since LTO_API_VERSION=7 @@ -854,7 +846,47 @@ thinlto_codegen_set_cache_size_megabytes(thinlto_code_gen_t cg, extern void thinlto_codegen_set_cache_size_files(thinlto_code_gen_t cg, unsigned max_size_files); - +/** Opaque reference to an LTO input file */ +typedef struct LLVMOpaqueLTOInput *lto_input_t; + +/** + * Creates an LTO input file from a buffer. The path + * argument is used for diagnotics as this function + * otherwise does not know which file the given buffer + * is associated with. + * + * \since LTO_API_VERSION=24 + */ +extern lto_input_t lto_input_create(const void *buffer, + size_t buffer_size, + const char *path); + +/** + * Frees all memory internally allocated by the LTO input file. + * Upon return the lto_module_t is no longer valid. + * + * \since LTO_API_VERSION=24 + */ +extern void lto_input_dispose(lto_input_t input); + +/** + * Returns the number of dependent library specifiers + * for the given LTO input file. + * + * \since LTO_API_VERSION=24 + */ +extern unsigned lto_input_get_num_dependent_libraries(lto_input_t input); + +/** + * Returns the ith dependent library specifier + * for the given LTO input file. The returned + * string is not null-terminated. + * + * \since LTO_API_VERSION=24 + */ +extern const char * lto_input_get_dependent_library(lto_input_t input, + size_t index, + size_t *size); /** * @} // endgroup LLVMCTLTO_CACHING |