[llvm] r325947 - [WebAssembly] Fix macro metaprogram to not duplicate code as much.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 12:13:03 PST 2018


Author: d0k
Date: Fri Feb 23 12:13:03 2018
New Revision: 325947

URL: http://llvm.org/viewvc/llvm-project?rev=325947&view=rev
Log:
[WebAssembly] Fix macro metaprogram to not duplicate code as much.

No functionality change intended.

Modified:
    llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp

Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp?rev=325947&r1=325946&r2=325947&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp Fri Feb 23 12:13:03 2018
@@ -465,15 +465,19 @@ ManagedStatic<RuntimeLibcallSignatureTab
 struct StaticLibcallNameMap {
   StringMap<RTLIB::Libcall> 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<const char *, RTLIB::Libcall> 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;
+      }
+    }
   }
 };
 




More information about the llvm-commits mailing list