[PATCH] D44150: [WebAssembly] Use DenseMapInfo traits from LLVM repo. NFC

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 14 09:00:49 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD327527: [WebAssembly] Use DenseMapInfo traits from LLVM repo. NFC (authored by ncw, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44150?vs=137747&id=138383#toc

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D44150

Files:
  wasm/Writer.cpp
  wasm/WriterUtils.h


Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -21,6 +21,7 @@
 #include "lld/Common/Threads.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/BinaryFormat/Wasm.h"
+#include "llvm/Object/WasmTraits.h"
 #include "llvm/Support/FileOutputBuffer.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -41,29 +42,6 @@
 
 namespace {
 
-// Traits for using WasmSignature in a DenseMap.
-struct WasmSignatureDenseMapInfo {
-  static WasmSignature getEmptyKey() {
-    WasmSignature Sig;
-    Sig.ReturnType = 1;
-    return Sig;
-  }
-  static WasmSignature getTombstoneKey() {
-    WasmSignature Sig;
-    Sig.ReturnType = 2;
-    return Sig;
-  }
-  static unsigned getHashValue(const WasmSignature &Sig) {
-    unsigned H = hash_value(Sig.ReturnType);
-    for (int32_t Param : Sig.ParamTypes)
-      H = hash_combine(H, Param);
-    return H;
-  }
-  static bool isEqual(const WasmSignature &LHS, const WasmSignature &RHS) {
-    return LHS == RHS;
-  }
-};
-
 // An init entry to be written to either the synthetic init func or the
 // linking metadata.
 struct WasmInitEntry {
@@ -120,7 +98,7 @@
   uint32_t MaxMemoryPages = 0;
 
   std::vector<const WasmSignature *> Types;
-  DenseMap<WasmSignature, int32_t, WasmSignatureDenseMapInfo> TypeIndices;
+  DenseMap<WasmSignature, int32_t> TypeIndices;
   std::vector<const Symbol *> ImportedSymbols;
   unsigned NumImportedFunctions = 0;
   unsigned NumImportedGlobals = 0;
Index: wasm/WriterUtils.h
===================================================================
--- wasm/WriterUtils.h
+++ wasm/WriterUtils.h
@@ -17,28 +17,6 @@
 
 using llvm::raw_ostream;
 
-// Needed for WasmSignatureDenseMapInfo
-inline bool operator==(const llvm::wasm::WasmSignature &LHS,
-                       const llvm::wasm::WasmSignature &RHS) {
-  return LHS.ReturnType == RHS.ReturnType && LHS.ParamTypes == RHS.ParamTypes;
-}
-
-inline bool operator!=(const llvm::wasm::WasmSignature &LHS,
-                       const llvm::wasm::WasmSignature &RHS) {
-  return !(LHS == RHS);
-}
-
-// Used for general comparison
-inline bool operator==(const llvm::wasm::WasmGlobalType &LHS,
-                       const llvm::wasm::WasmGlobalType &RHS) {
-  return LHS.Type == RHS.Type && LHS.Mutable == RHS.Mutable;
-}
-
-inline bool operator!=(const llvm::wasm::WasmGlobalType &LHS,
-                       const llvm::wasm::WasmGlobalType &RHS) {
-  return !(LHS == RHS);
-}
-
 namespace lld {
 namespace wasm {
 
@@ -75,7 +53,7 @@
 
 } // namespace wasm
 
-std::string toString(const llvm::wasm::ValType Type);
+std::string toString(llvm::wasm::ValType Type);
 std::string toString(const llvm::wasm::WasmSignature &Sig);
 std::string toString(const llvm::wasm::WasmGlobalType &Sig);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44150.138383.patch
Type: text/x-patch
Size: 2826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180314/5df61b38/attachment.bin>


More information about the llvm-commits mailing list