https://github.com/ChuanqiXu9 created https://github.com/llvm/llvm-project/pull/95730
See the comment: https://github.com/llvm/llvm-project/pull/92083#issuecomment-2168121729 After the patch, https://github.com/llvm/llvm-project/pull/92083, the lower 32 bits of DeclID can be the same commonly. This may produce many collisions. It will be best to change the default hash implementation for uint64_t. But sent this one as a quick workaround. >From 50923aa33f09b2530cfe492a53f70296f9ce9107 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu <yedeng...@linux.alibaba.com> Date: Mon, 17 Jun 2024 11:32:35 +0800 Subject: [PATCH] [Serialization] Use specialized decl hash function for GlobalDeclID See the comment: https://github.com/llvm/llvm-project/pull/92083#issuecomment-2168121729 After the patch, https://github.com/llvm/llvm-project/pull/92083, the lower 32 bits of DeclID can be the same commonly. This may produce many collisions. It will be best to change the default hash implementation for uint64_t. But sent this one as a quick workaround. --- clang/include/clang/AST/DeclID.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h index 32d2ed41a374a..4ad7afb463b18 100644 --- a/clang/include/clang/AST/DeclID.h +++ b/clang/include/clang/AST/DeclID.h @@ -230,7 +230,11 @@ template <> struct DenseMapInfo<clang::GlobalDeclID> { } static unsigned getHashValue(const GlobalDeclID &Key) { - return DenseMapInfo<DeclID>::getHashValue(Key.get()); + // Our default hash algorithm for 64 bits integer may not be very good. + // In GlobalDeclID's case, it is pretty common that the lower 32 bits can + // be same. + return DenseMapInfo<uint32_t>::getHashValue(Key.getModuleFileIndex()) ^ + DenseMapInfo<uint32_t>::getHashValue(Key.getLocalDeclIndex()); } static bool isEqual(const GlobalDeclID &L, const GlobalDeclID &R) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits