Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -40,29 +40,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 { @@ -119,7 +96,7 @@ uint32_t NumMemoryPages = 0; std::vector Types; - DenseMap TypeIndices; + DenseMap TypeIndices; std::vector ImportedSymbols; unsigned NumImportedFunctions = 0; unsigned NumImportedGlobals = 0; Index: wasm/WriterUtils.h =================================================================== --- wasm/WriterUtils.h +++ wasm/WriterUtils.h @@ -11,13 +11,16 @@ #define LLD_WASM_WRITERUTILS_H #include "lld/Common/LLVM.h" +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/Twine.h" #include "llvm/Object/Wasm.h" #include "llvm/Support/raw_ostream.h" using llvm::raw_ostream; -// Needed for WasmSignatureDenseMapInfo +namespace llvm { + +// Needed for DenseMapInfo inline bool operator==(const llvm::wasm::WasmSignature &LHS, const llvm::wasm::WasmSignature &RHS) { return LHS.ReturnType == RHS.ReturnType && LHS.ParamTypes == RHS.ParamTypes; @@ -39,6 +42,32 @@ return !(LHS == RHS); } +// Traits for using WasmSignature in a DenseMap. +template<> struct DenseMapInfo { + static wasm::WasmSignature getEmptyKey() { + wasm::WasmSignature Sig; + Sig.ReturnType = 1; + return Sig; + } + static wasm::WasmSignature getTombstoneKey() { + wasm::WasmSignature Sig; + Sig.ReturnType = 2; + return Sig; + } + static unsigned getHashValue(const wasm::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 wasm::WasmSignature &LHS, + const wasm::WasmSignature &RHS) { + return LHS == RHS; + } +}; + +} // end namespace llvm + namespace lld { namespace wasm {