[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 20:39:40 PST 2025
================
@@ -90,23 +93,24 @@ class BPSectionMacho : public BPSectionBase {
§ionToIdx) const override {
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));
- }
+ // Calculate content hashes: k-mers and the last k-1 bytes.
+ ArrayRef<uint8_t> data = isec->data;
+ if (data.size() >= windowSize)
+ for (size_t i = 0; i <= data.size() - windowSize; ++i)
+ hashes.push_back(llvm::support::endian::read32le(data.data() + i));
----------------
ellishg wrote:
Why are we using `read32le()` here and `xxh3_64bits()` for relocations below? As I understand, `read32le()` only works here because the window size is exactly 4. I chose this window size because it gave the best results on a few binaries, but other window sizes could work better for other scenarios. If we use `xxh3_64bits()` in both cases, we are free to change `windowSize`.
https://github.com/llvm/llvm-project/pull/121729
More information about the llvm-commits
mailing list