aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
diff options
context:
space:
mode:
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