[llvm] [CodeGen] Make hash_value a non-friend function (NFC) (PR #137564)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 27 17:51:00 PDT 2025


================
@@ -96,7 +94,7 @@ class Vector {
 inline hash_code hash_value(const Vector &V) {
   const unsigned *VBegin = reinterpret_cast<const unsigned *>(V.begin());
   const unsigned *VEnd = reinterpret_cast<const unsigned *>(V.end());
-  return hash_combine(V.Data.size(), hash_combine_range(VBegin, VEnd));
+  return hash_combine(V.getLength(), hash_combine_range(VBegin, VEnd));
----------------
kazutakahirata wrote:

No, I get:

```
llvm/include/llvm/ADT/Hashing.h:365:10: error: call to function 'hash_valu
e' that is neither visible in the template definition nor found by argument-dependent lookup                                
  return hash_value(value);                                                                                                 
         ^                                                                                                                  
```

This is most likely because `float` is not supported.

We could do:

```
  auto BitCast = llvm::bit_cast<unsigned, PBQPNum>;
  return hash_combine(V.getLength(), hash_combine_range(map_range(V, BitCast)));
```

I've got a temporary variable `BitCast` here to fit to prevent clang-format from consuming three lines.

Thoughts?


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


More information about the llvm-commits mailing list