[PATCH] D67568: [LTO][Legacy] Add new C inferface to query libcall functions

Steven Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 12:32:30 PDT 2019


steven_wu created this revision.
steven_wu added reviewers: tejohnson, bd1976llvm.
Herald added subscribers: ributzka, dexonsmith, jkorous, inglorion, mehdi_amini.
Herald added a reviewer: deadalnix.
Herald added a project: LLVM.
steven_wu added a parent revision: D67565: [NFC][libLTO] Rearrange declaration in lto.h.

This is needed to implemented the same approach as lld (implemented in r338434)
for how to handling symbols that can be generated by LTO code generator
but not present in the symbol table for linker that uses legacy C APIs.

libLTO is in charge of providing the list of symbols. Linker is in
charge of implementing the eager loading from static libraries using
the list of symbols.

rdar://problem/52853974


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67568

Files:
  llvm/include/llvm-c/lto.h
  llvm/tools/lto/lto.cpp
  llvm/tools/lto/lto.exports


Index: llvm/tools/lto/lto.exports
===================================================================
--- llvm/tools/lto/lto.exports
+++ 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
Index: llvm/tools/lto/lto.cpp
===================================================================
--- llvm/tools/lto/lto.cpp
+++ 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];
+}
Index: llvm/include/llvm-c/lto.h
===================================================================
--- llvm/include/llvm-c/lto.h
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67568.220152.patch
Type: text/x-patch
Size: 2007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190913/e59432c7/attachment.bin>


More information about the llvm-commits mailing list