[lld] r338406 - Make ICF log output order deterministic.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 31 11:04:58 PDT 2018


Author: ruiu
Date: Tue Jul 31 11:04:58 2018
New Revision: 338406

URL: http://llvm.org/viewvc/llvm-project?rev=338406&view=rev
Log:
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

Modified:
    lld/trunk/COFF/ICF.cpp
    lld/trunk/ELF/ICF.cpp

Modified: lld/trunk/COFF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=338406&r1=338405&r2=338406&view=diff
==============================================================================
--- lld/trunk/COFF/ICF.cpp (original)
+++ lld/trunk/COFF/ICF.cpp Tue Jul 31 11:04:58 2018
@@ -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

Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=338406&r1=338405&r2=338406&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Tue Jul 31 11:04:58 2018
@@ -436,7 +436,7 @@ template <class ELFT> void ICF<ELFT>::ru
   // 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




More information about the llvm-commits mailing list