[PATCH] D43856: [WebAssembly] Improve WasmSignatureDenseMapInfo.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 27 19:56:17 PST 2018
ruiu created this revision.
ruiu added a reviewer: sbc100.
Herald added subscribers: sunfish, aheejin, jgravelle-google, dschuff, jfb.
Let X and Y be types. Previously, functions F(X, Y) and G(X, Y) had
the same hash value because their hash values are computed as follows:
hash(F) = hash(X) + hash(Y)
hash(G) = hash(Y) + hash(X)
This patch fixes the issue by using hash_combine.
https://reviews.llvm.org/D43856
Files:
lld/wasm/Writer.cpp
Index: lld/wasm/Writer.cpp
===================================================================
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -53,11 +53,10 @@
return Sig;
}
static unsigned getHashValue(const WasmSignature &Sig) {
- uintptr_t Value = 0;
- Value += DenseMapInfo<int32_t>::getHashValue(Sig.ReturnType);
+ unsigned H = hash_value(Sig.ReturnType);
for (int32_t Param : Sig.ParamTypes)
- Value += DenseMapInfo<int32_t>::getHashValue(Param);
- return Value;
+ H = hash_combine(H, Param);
+ return H;
}
static bool isEqual(const WasmSignature &LHS, const WasmSignature &RHS) {
return LHS == RHS;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43856.136222.patch
Type: text/x-patch
Size: 661 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180228/22b55627/attachment.bin>
More information about the llvm-commits
mailing list