[lld] [lld-macho,BalancedPartition] Simplify relocation hash and avoid xxHash (PR #121729)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 6 14:49:40 PST 2025


================
@@ -91,22 +94,20 @@ class BPSectionMacho : public BPSectionBase {
     constexpr unsigned windowSize = 4;
 
     // Calculate content hashes
-    size_t dataSize = isec->data.size();
-    for (size_t i = 0; i < dataSize; i++) {
-      auto window = isec->data.drop_front(i).take_front(windowSize);
-      hashes.push_back(xxHash64(window));
-    }
+    ArrayRef<uint8_t> data = isec->data;
+    for (size_t i = 0; i <= data.size() - windowSize; i++)
----------------
ellishg wrote:

> Sections shorter than 4 bytes are trivial functions that are likely
> foled by ICF.

We should still guard against the case when `data.size() < windowSize` because these sections could be data sections in the future

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


More information about the llvm-commits mailing list