[all-commits] [llvm/llvm-project] ce80c8: [Hashing] Use a non-deterministic seed if LLVM_ENA...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Fri Jun 28 15:30:41 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ce80c80dca45c7b4636a3e143973e2c6cbdb2884
https://github.com/llvm/llvm-project/commit/ce80c80dca45c7b4636a3e143973e2c6cbdb2884
Author: Fangrui Song <i at maskray.me>
Date: 2024-06-28 (Fri, 28 Jun 2024)
Changed paths:
M llvm/include/llvm/ADT/Hashing.h
M llvm/lib/Support/CMakeLists.txt
R llvm/lib/Support/Hashing.cpp
M llvm/unittests/ADT/HashingTest.cpp
M llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
Log Message:
-----------
[Hashing] Use a non-deterministic seed if LLVM_ENABLE_ABI_BREAKING_CHECKS
Hashing.h provides hash_value/hash_combine/hash_combine_range, which are
primarily used by `DenseMap<StringRef, X>`
Users shouldn't rely on specific hash values due to size_t differences
on 32-bit/64-bit platforms and potential algorithm changes.
`set_fixed_execution_hash_seed` is provided but it has never been used.
In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, take the the address of a
static storage duration variable as the seed like
absl/hash/internal/hash.h `kSeed`. (See https://reviews.llvm.org/D93931
for workaround for older Clang. Mach-O x86-64 forces PIC, so absl's
`__apple_build_version__` check is unnecessary.)
LLVM_ENABLE_ABI_BREAKING_CHECKS defaults to `WITH_ASSERTS` and is
enabled in an assertion build.
In a non-assertion build, `get_execution_seed` returns the fixed value
regardless of `NDEBUG`. Removing a variable load yields noticeable
size/performance improvement.
A few users relying on the iteration order of `DenseMap<StringRef, X>`
have been fixed (e.g., f8f4235612b9 c025bd1fdbbd 89e8e63f47ff
86eb6bf6715c eb8d03656549 0ea6b8e476c2 58d7a6e0e636 8ea31db27211
592abf29f9f7 664497557ae7).
>From my experience fixing [`StringMap`](https://discourse.llvm.org/t/reverse-iteration-bots/72224)
iteration order issues, the scale of issues is similar.
Pull Request: https://github.com/llvm/llvm-project/pull/96282
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list