aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2025-06-20 09:35:02 +0900
committerGitHub <noreply@github.com>2025-06-20 09:35:02 +0900
commitefd42b9b1d655a56abb3e6ce1ed4414e9f882912 (patch)
treee2d6b7a32e2eac76a96d4feffe86962417d2aa3c /llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
parent91439817e8d19613ac6e25ca9abd5e7534a9d33b (diff)
downloadllvm-efd42b9b1d655a56abb3e6ce1ed4414e9f882912.zip
llvm-efd42b9b1d655a56abb3e6ce1ed4414e9f882912.tar.gz
llvm-efd42b9b1d655a56abb3e6ce1ed4414e9f882912.tar.bz2
WebAssembly: Stop directly using RuntimeLibcalls.def (#143054)
Construct RuntimeLibcallsInfo instead of manually creating a map. This was repeating the setting of the RETURN_ADDRESS. This removes an obstacle to generating libcall information with tablegen. This is also not great, since it's setting a static map which would be broken if there were ever a triple with a different libcall configuration.
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
index d5c4532..4548a75 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
@@ -528,25 +528,19 @@ RuntimeLibcallSignatureTable &getRuntimeLibcallSignatures() {
// constructor for use with a static variable
struct StaticLibcallNameMap {
StringMap<RTLIB::Libcall> Map;
- StaticLibcallNameMap() {
- static const std::pair<const char *, RTLIB::Libcall> NameLibcalls[] = {
-#define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code},
-#define LIBCALL_NO_NAME nullptr
-#include "llvm/IR/RuntimeLibcalls.def"
-#undef HANDLE_LIBCALL
-#undef LIBCALL_NO_NAME
- };
- for (const auto &NameLibcall : NameLibcalls) {
- if (NameLibcall.first != nullptr &&
- getRuntimeLibcallSignatures().Table[NameLibcall.second] !=
- unsupported) {
- assert(!Map.contains(NameLibcall.first) &&
+ StaticLibcallNameMap(const Triple &TT) {
+ // FIXME: This is broken if there are ever different triples compiled with
+ // different libcalls.
+ RTLIB::RuntimeLibcallsInfo RTCI(TT);
+ for (RTLIB::Libcall LC : RTLIB::libcalls()) {
+ const char *NameLibcall = RTCI.getLibcallName(LC);
+ if (NameLibcall != nullptr &&
+ getRuntimeLibcallSignatures().Table[LC] != unsupported) {
+ assert(!Map.contains(NameLibcall) &&
"duplicate libcall names in name map");
- Map[NameLibcall.first] = NameLibcall.second;
+ Map[NameLibcall] = LC;
}
}
-
- Map["emscripten_return_address"] = RTLIB::RETURN_ADDRESS;
}
};
@@ -942,7 +936,7 @@ void WebAssembly::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
StringRef Name,
SmallVectorImpl<wasm::ValType> &Rets,
SmallVectorImpl<wasm::ValType> &Params) {
- static StaticLibcallNameMap LibcallNameMap;
+ static StaticLibcallNameMap LibcallNameMap(Subtarget.getTargetTriple());
auto &Map = LibcallNameMap.Map;
auto Val = Map.find(Name);
#ifndef NDEBUG