Index: lld/trunk/COFF/ICF.cpp =================================================================== --- lld/trunk/COFF/ICF.cpp +++ lld/trunk/COFF/ICF.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Parallel.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/xxhash.h" #include #include #include @@ -65,13 +66,6 @@ std::atomic Repeat = {false}; }; -// Returns a hash value for S. -uint32_t ICF::getHash(SectionChunk *C) { - return hash_combine(C->getOutputCharacteristics(), C->SectionName, - C->Relocs.size(), uint32_t(C->Header->SizeOfRawData), - C->Checksum, C->getContents()); -} - // Returns true if section S is subject of ICF. // // Microsoft's documentation @@ -265,7 +259,7 @@ // Initially, we use hash values to partition sections. for_each(parallel::par, Chunks.begin(), Chunks.end(), [&](SectionChunk *SC) { // Set MSB to 1 to avoid collisions with non-hash classs. - SC->Class[0] = getHash(SC) | (1 << 31); + SC->Class[0] = xxHash64(SC->getContents()) | (1 << 31); }); // From now on, sections in Chunks are ordered so that sections in Index: lld/trunk/ELF/ICF.cpp =================================================================== --- lld/trunk/ELF/ICF.cpp +++ lld/trunk/ELF/ICF.cpp @@ -436,7 +436,7 @@ // Initially, we use hash values to partition sections. parallelForEach(Sections, [&](InputSection *S) { // Set MSB to 1 to avoid collisions with non-hash IDs. - S->Class[0] = xxHash64(toStringRef(S->Data)) | (1U << 31); + S->Class[0] = xxHash64(S->Data) | (1U << 31); }); // From now on, sections in Sections vector are ordered so that sections Index: llvm/trunk/include/llvm/Support/xxhash.h =================================================================== --- llvm/trunk/include/llvm/Support/xxhash.h +++ llvm/trunk/include/llvm/Support/xxhash.h @@ -38,10 +38,12 @@ #ifndef LLVM_SUPPORT_XXHASH_H #define LLVM_SUPPORT_XXHASH_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" namespace llvm { uint64_t xxHash64(llvm::StringRef Data); +uint64_t xxHash64(llvm::ArrayRef Data); } #endif Index: llvm/trunk/lib/Support/xxhash.cpp =================================================================== --- llvm/trunk/lib/Support/xxhash.cpp +++ llvm/trunk/lib/Support/xxhash.cpp @@ -132,3 +132,7 @@ return H64; } + +uint64_t llvm::xxHash64(ArrayRef Data) { + return xxHash64({(const char *)Data.data(), Data.size()}); +}