From c7b23d8d31776b123b2b786bf7f1cf60b7234c38 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Mon, 17 Jun 2024 11:37:25 +0800 Subject: [PATCH 1/4] [ADT] Update hash function of uint64_t for DenseMap --- llvm/include/llvm/ADT/DenseMapInfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h index 5b7dce7b53c62..61869d8e7fbb0 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -151,7 +151,7 @@ template<> struct DenseMapInfo { static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return (unsigned)(Val * 37ULL); + return DenseMapInfo(Val) ^ DenseMapInfo(Val >> 32); } static bool isEqual(const unsigned long long& LHS, From 773ade75191b0a8e988ce38e57de3416f1610ae4 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Mon, 17 Jun 2024 13:17:49 +0800 Subject: [PATCH 2/4] Update --- llvm/include/llvm/ADT/DenseMapInfo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h index 61869d8e7fbb0..0def1dccdf4c3 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -151,7 +151,8 @@ template<> struct DenseMapInfo { static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return DenseMapInfo(Val) ^ DenseMapInfo(Val >> 32); + return DenseMapInfo::getHashValue(Val) ^ + DenseMapInfo::getHashValue(Val >> 32); } static bool isEqual(const unsigned long long& LHS, From 0456725d21b48191f4e828e33859b7c72d9d7f36 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Tue, 18 Jun 2024 10:07:57 +0800 Subject: [PATCH 3/4] Update --- llvm/include/llvm/ADT/DenseMapInfo.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h index 0def1dccdf4c3..b039afee66c10 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -137,7 +137,12 @@ template<> struct DenseMapInfo { static inline unsigned long getTombstoneKey() { return ~0UL - 1L; } static unsigned getHashValue(const unsigned long& Val) { - return (unsigned)(Val * 37UL); + if constexpr (sizeof(Val) == 4) + return DenseMapInfo::getHashValue(Val); + else + return detail::combineHashValue( + DenseMapInfo::getHashValue(Val), + DenseMapInfo::getHashValue(Val >> 32)); } static bool isEqual(const unsigned long& LHS, const unsigned long& RHS) { @@ -151,8 +156,9 @@ template<> struct DenseMapInfo { static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return DenseMapInfo::getHashValue(Val) ^ - DenseMapInfo::getHashValue(Val >> 32); + return detail::combineHashValue( + DenseMapInfo::getHashValue(Val), + DenseMapInfo::getHashValue(Val >> 32)); } static bool isEqual(const unsigned long long& LHS, From b6eac6d661e773096a0508f0e4ce54053bc641ed Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Wed, 19 Jun 2024 10:09:53 +0800 Subject: [PATCH 4/4] Update --- llvm/include/llvm/ADT/DenseMapInfo.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h index b039afee66c10..2e71eb4bfae77 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -140,9 +140,7 @@ template<> struct DenseMapInfo { if constexpr (sizeof(Val) == 4) return DenseMapInfo::getHashValue(Val); else - return detail::combineHashValue( - DenseMapInfo::getHashValue(Val), - DenseMapInfo::getHashValue(Val >> 32)); + return detail::combineHashValue(Val >> 32, Val); } static bool isEqual(const unsigned long& LHS, const unsigned long& RHS) { @@ -156,9 +154,7 @@ template<> struct DenseMapInfo { static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return detail::combineHashValue( - DenseMapInfo::getHashValue(Val), - DenseMapInfo::getHashValue(Val >> 32)); + return detail::combineHashValue(Val >> 32, Val); } static bool isEqual(const unsigned long long& LHS,