[llvm] [BOLT] Provide backwards compatibility for YAML profile with std::hash (PR #74253)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 14:51:04 PDT 2024


================
@@ -241,12 +241,26 @@ void BinaryFunction::computeBlockHashes() const {
     // Hashing complete instructions.
     std::string InstrHashStr = hashBlock(
         BC, *BB, [&](const MCOperand &Op) { return hashInstOperand(BC, Op); });
-    uint64_t InstrHash = llvm::xxh3_64bits(InstrHashStr);
-    BlendedHashes[I].InstrHash = (uint16_t)InstrHash;
+    if (HashFunction == HashFunction::StdHash) {
+      uint64_t InstrHash = std::hash<std::string>{}(InstrHashStr);
+      BlendedHashes[I].InstrHash = (uint16_t)hash_value(InstrHash);
----------------
MaskRay wrote:

`std::hash<std::string>` results are quite good and do not need another bit mixer.

`llvm::hash_value` is non-deterministic (#96282).

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


More information about the llvm-commits mailing list