diff options
author | Rui Ueyama <ruiu@google.com> | 2018-07-31 18:04:58 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2018-07-31 18:04:58 +0000 |
commit | 7f97570e79fffc25e204617714be2355f4af4c47 (patch) | |
tree | 2b54b2e389ba22e40c064f76919851fa0e37e374 | |
parent | 1f6fb8d06394961049e48f7f16ce81538e38b778 (diff) | |
download | bcm5719-llvm-7f97570e79fffc25e204617714be2355f4af4c47.tar.gz bcm5719-llvm-7f97570e79fffc25e204617714be2355f4af4c47.zip |
Make ICF log output order deterministic.
This patch does the same thing as r338153 for COFF.
Note that this patch affects only the order of log messages.
The output file is already deterministic.
Differential Revision: https://reviews.llvm.org/D50023
llvm-svn: 338406
-rw-r--r-- | lld/COFF/ICF.cpp | 10 | ||||
-rw-r--r-- | lld/ELF/ICF.cpp | 2 | ||||
-rw-r--r-- | llvm/include/llvm/Support/xxhash.h | 2 | ||||
-rw-r--r-- | llvm/lib/Support/xxhash.cpp | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/lld/COFF/ICF.cpp b/lld/COFF/ICF.cpp index 629720901ab..7feb3c4e0b0 100644 --- a/lld/COFF/ICF.cpp +++ b/lld/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 <algorithm> #include <atomic> #include <vector> @@ -65,13 +66,6 @@ private: std::atomic<bool> 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 @@ void ICF::run(ArrayRef<Chunk *> Vec) { // 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 diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index 53569c27544..075938bd16b 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -436,7 +436,7 @@ template <class ELFT> void ICF<ELFT>::run() { // 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 diff --git a/llvm/include/llvm/Support/xxhash.h b/llvm/include/llvm/Support/xxhash.h index f7ca460188a..6fd67ff9ce1 100644 --- a/llvm/include/llvm/Support/xxhash.h +++ b/llvm/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<uint8_t> Data); } #endif diff --git a/llvm/lib/Support/xxhash.cpp b/llvm/lib/Support/xxhash.cpp index df643f9bd63..e9dceed2c4a 100644 --- a/llvm/lib/Support/xxhash.cpp +++ b/llvm/lib/Support/xxhash.cpp @@ -132,3 +132,7 @@ uint64_t llvm::xxHash64(StringRef Data) { return H64; } + +uint64_t llvm::xxHash64(ArrayRef<uint8_t> Data) { + return xxHash64({(const char *)Data.data(), Data.size()}); +} |