diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h --- a/llvm/include/llvm-c/lto.h +++ b/llvm/include/llvm-c/lto.h @@ -44,7 +44,7 @@ * @{ */ -#define LTO_API_VERSION 24 +#define LTO_API_VERSION 25 /** * \since prior to LTO_API_VERSION=3 @@ -793,6 +793,23 @@ size_t index, size_t *size); +/** + * Returns the number of libcall symbols that can be generated by LTO + * code generator that might not be visile from the symbol table of + * bitcode files. + * + * \since prior to LTO_API_VERSION=25 + */ +extern unsigned int +lto_get_num_runtime_lib_symbols(); + +/** + * Returns the name of the ith symbol in the list of possible libcall symbols. + * + * \since prior to LTO_API_VERSION=25 + */ +extern const char* +lto_get_runtime_lib_symbol_name(unsigned int index); /** * @} // endgoup LLVMCTLTO diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -652,3 +652,18 @@ size_t *size) { return LTOModule::getDependentLibrary(unwrap(input), index, size); } + +static const char *libcallRoutineNames[] = { +#define HANDLE_LIBCALL(code, name) name, +#include "llvm/IR/RuntimeLibcalls.def" +#undef HANDLE_LIBCALL +}; + +unsigned int lto_get_num_runtime_lib_symbols() { + return makeArrayRef(libcallRoutineNames).size(); +} + +const char* +lto_get_runtime_lib_symbol_name(unsigned int index) { + return makeArrayRef(libcallRoutineNames)[index]; +} diff --git a/llvm/tools/lto/lto.exports b/llvm/tools/lto/lto.exports --- a/llvm/tools/lto/lto.exports +++ b/llvm/tools/lto/lto.exports @@ -76,3 +76,5 @@ lto_input_dispose lto_input_get_num_dependent_libraries lto_input_get_dependent_library +lto_get_num_runtime_lib_symbols +lto_get_runtime_lib_symbol_name