llvm-project
ce80c80d - [Hashing] Use a non-deterministic seed if LLVM_ENABLE_ABI_BREAKING_CHECKS

Commit
1 year ago
[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
Author
Parents
Loading