[llvm] ff6ab75 - [llvm-c][lto] Add lto_runtime_lib_symbols_list_for_triple (#221217)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 06:26:21 PDT 2026
Author: Francesco Petrogalli
Date: 2026-09-09T06:26:14-07:00
New Revision: ff6ab759dbfd69a7b8138ed782f09dc979bad72e
URL: https://github.com/llvm/llvm-project/commit/ff6ab759dbfd69a7b8138ed782f09dc979bad72e
DIFF: https://github.com/llvm/llvm-project/commit/ff6ab759dbfd69a7b8138ed782f09dc979bad72e.diff
LOG: [llvm-c][lto] Add lto_runtime_lib_symbols_list_for_triple (#221217)
The TableGen-generated `setTargetRuntimeLibcallSets` that is reached via
`getRuntimeLibcallSymbols` has no unconditional block — every branch is
arch-gated and returns, so an unknown triple sets nothing available, and
the list of symbols comes back empty.
This patch adds a second entry point to the C LTO API that takes a
triple and passes it along.
Bump `LTO_API_VERSION`.
Added:
Modified:
llvm/include/llvm-c/lto.h
llvm/tools/lto/lto.cpp
llvm/tools/lto/lto.exports
Removed:
################################################################################
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index d0a92a6db90d5..09bdba5d299a0 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -47,7 +47,7 @@ typedef bool lto_bool_t;
* @{
*/
-#define LTO_API_VERSION 30
+#define LTO_API_VERSION 31
/**
* \since prior to LTO_API_VERSION=3
@@ -648,6 +648,9 @@ LLVM_C_ABI extern const char *
lto_input_get_dependent_library(lto_input_t input, size_t index, size_t *size);
/**
+ * Deprecated from LTO_API_VERSION=31: use
+ * `lto_runtime_lib_symbols_list_for_triple`.
+ *
* Returns the list of libcall symbols that can be generated by LTO
* that might not be visible from the symbol table of bitcode files.
*
@@ -655,6 +658,15 @@ lto_input_get_dependent_library(lto_input_t input, size_t index, size_t *size);
*/
LLVM_C_ABI extern const char *const *lto_runtime_lib_symbols_list(size_t *size);
+/**
+ * For a given triple, returns the list of libcall symbols that can be generated
+ * by LTO that might not be visible from the symbol table of bitcode files.
+ *
+ * \since LTO_API_VERSION=31
+ */
+LLVM_C_ABI extern const char *const *
+lto_runtime_lib_symbols_list_for_triple(const char *TT, size_t *size);
+
/**
* @} // endgoup LLVMCLTO
* @defgroup LLVMCTLTO ThinLTO
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index 214cf85e432bc..84347bbaa8dc3 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -752,3 +752,14 @@ extern const char *const *lto_runtime_lib_symbols_list(size_t *size) {
*size = RuntimeLibcallSymbols.size();
return RuntimeLibcallSymbols.data();
}
+
+extern const char *const *
+lto_runtime_lib_symbols_list_for_triple(const char *TS, size_t *size) {
+ static StringMap<SmallVector<const char *>> RTLibcallSymMap;
+ Triple TT(TS);
+ auto [It, Inserted] = RTLibcallSymMap.try_emplace(TT.normalize());
+ if (Inserted)
+ It->second = lto::LTO::getRuntimeLibcallSymbols(TT);
+ *size = It->second.size();
+ return It->second.data();
+}
diff --git a/llvm/tools/lto/lto.exports b/llvm/tools/lto/lto.exports
index 850e159b725a3..8f76197496031 100644
--- a/llvm/tools/lto/lto.exports
+++ b/llvm/tools/lto/lto.exports
@@ -77,3 +77,4 @@ lto_input_dispose
lto_input_get_num_dependent_libraries
lto_input_get_dependent_library
lto_runtime_lib_symbols_list
+lto_runtime_lib_symbols_list_for_triple
More information about the llvm-commits
mailing list