From c213d8cb04abe37bf94ad9389cfcd6ba324d4e2b Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 20 Jun 2024 12:36:48 +0100 Subject: [PATCH 1/3] [ADT] DenseMapInfo::getHashValue - avoid MSVC out of bounds shift warning Fixes MSVC warning after #95734 - despite it taking the `sizeof(Val) == 4` path, it still warns that the 32-bit unsigned long shift by 32 is out of bounds, so avoid it by converting the hard coded shift amount to be based off sizeof() instead. --- 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 4f0aaa1ad48bb..3d83a2c1473f5 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -142,7 +142,7 @@ template<> struct DenseMapInfo { if constexpr (sizeof(Val) == 4) return DenseMapInfo::getHashValue(Val); else - return detail::combineHashValue(Val >> 32, Val); + return detail::combineHashValue(Val >> (4 * sizeof(Val)), Val); } static bool isEqual(const unsigned long& LHS, const unsigned long& RHS) { From c484ded6a017f4400a6099af66706d0f35b9de2b Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 20 Jun 2024 12:46:14 +0100 Subject: [PATCH 2/3] Use densemap::detail::mix(Val) instead --- 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 3d83a2c1473f5..a5ef92c478552 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -142,7 +142,7 @@ template<> struct DenseMapInfo { if constexpr (sizeof(Val) == 4) return DenseMapInfo::getHashValue(Val); else - return detail::combineHashValue(Val >> (4 * sizeof(Val)), Val); + return densemap::detail::mix(Val); } static bool isEqual(const unsigned long& LHS, const unsigned long& RHS) { From ffa04f0b5295524188063ef9fbaf1c4f755a4ab7 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 20 Jun 2024 13:05:10 +0100 Subject: [PATCH 3/3] Use densemap::detail::mix(Val) for the unsigned long long case as well --- 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 a5ef92c478552..07c37e353a40b 100644 --- a/llvm/include/llvm/ADT/DenseMapInfo.h +++ b/llvm/include/llvm/ADT/DenseMapInfo.h @@ -156,7 +156,7 @@ template<> struct DenseMapInfo { static inline unsigned long long getTombstoneKey() { return ~0ULL - 1ULL; } static unsigned getHashValue(const unsigned long long& Val) { - return detail::combineHashValue(Val >> 32, Val); + return densemap::detail::mix(Val); } static bool isEqual(const unsigned long long& LHS,