From ae87f86ec4da5afc28e66a5248e359607d6f3436 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 23 Feb 2018 20:13:03 +0000 Subject: [WebAssembly] Fix macro metaprogram to not duplicate code as much. No functionality change intended. llvm-svn: 325947 --- .../WebAssemblyRuntimeLibcallSignatures.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp index d4d41520666..e2b518104d1 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp @@ -465,15 +465,19 @@ ManagedStatic RuntimeLibcallSignatures; struct StaticLibcallNameMap { StringMap Map; StaticLibcallNameMap() { -#define HANDLE_LIBCALL(code, name) \ - if ((const char *)name && \ - RuntimeLibcallSignatures->Table[RTLIB::code] != unsupported) { \ - assert(Map.find(StringRef::withNullAsEmpty(name)) == Map.end() && \ - "duplicate libcall names in name map"); \ - Map[StringRef::withNullAsEmpty(name)] = RTLIB::code; \ - } + static constexpr std::pair NameLibcalls[] = { +#define HANDLE_LIBCALL(code, name) {(const char *)name, RTLIB::code}, #include "llvm/CodeGen/RuntimeLibcalls.def" #undef HANDLE_LIBCALL + }; + for (const auto &NameLibcall : NameLibcalls) { + if (NameLibcall.first != nullptr && + RuntimeLibcallSignatures->Table[NameLibcall.second] != unsupported) { + assert(Map.find(NameLibcall.first) == Map.end() && + "duplicate libcall names in name map"); + Map[NameLibcall.first] = NameLibcall.second; + } + } } }; -- cgit v1.2.3