[llvm] [Hashing] Replace CityHash mixers with xxh3 (PR #194567)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Sat May 9 11:13:31 PDT 2026


================
@@ -589,10 +314,14 @@ struct hash_combine_recursive_helper {
 /// The result is suitable for returning from a user's hash_value
 /// *implementation* for their user-defined type. Consumers of a type should
 /// *not* call this routine, they should instead call 'hash_value'.
-template <typename ...Ts> hash_code hash_combine(const Ts &...args) {
-  // Recursively hash each argument using a helper class.
-  ::llvm::hashing::detail::hash_combine_recursive_helper helper;
-  return helper.combine(0, helper.buffer, helper.buffer + 64, args...);
+template <typename... Ts> hash_code hash_combine(const Ts &...args) {
+  constexpr size_t Total = hashing::detail::total_hashable_size<Ts...>();
+  // Round up so `data()` is non-null when Total == 0; combine_bytes won't
+  // read the buffer in that case (len=0 short-circuits in xxh3_64bits).
+  std::array<char, Total == 0 ? 1 : Total> buf;
----------------
kuhar wrote:

nit/optional: this could be `std::max(1, Total)`

https://github.com/llvm/llvm-project/pull/194567


More information about the llvm-commits mailing list