summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-02-28 17:32:50 +0000
committerRui Ueyama <ruiu@google.com>2018-02-28 17:32:50 +0000
commitba16baccf1ce8851220fdedbab6653a0d1a4bb80 (patch)
treea4a7deb54f002add85b2590974372d959c89ac1d
parent280f872bb23dcfdf312ae914a10e9079b4f1b670 (diff)
downloadbcm5719-llvm-ba16baccf1ce8851220fdedbab6653a0d1a4bb80.tar.gz
bcm5719-llvm-ba16baccf1ce8851220fdedbab6653a0d1a4bb80.zip
[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 llvm-svn: 326336
-rw-r--r--lld/wasm/Writer.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 0cd47589691..539bf8b9ce1 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -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;
OpenPOWER on IntegriCloud