[lld] r326336 - [WebAssembly] Improve WasmSignatureDenseMapInfo.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 09:32:51 PST 2018
Author: ruiu
Date: Wed Feb 28 09:32:50 2018
New Revision: 326336
URL: http://llvm.org/viewvc/llvm-project?rev=326336&view=rev
Log:
[WebAssembly] Improve WasmSignatureDenseMapInfo.
Let X and Y be types. Previously, functions F(X, Y) and G(Y, X) 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.
Differential Revision: https://reviews.llvm.org/D43856
Modified:
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=326336&r1=326335&r2=326336&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Wed Feb 28 09:32:50 2018
@@ -53,11 +53,10 @@ struct WasmSignatureDenseMapInfo {
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;
More information about the llvm-commits
mailing list