[PATCH] D50023: Make ICF output deterministic.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 31 11:05:23 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338406: Make ICF log output order deterministic. (authored by ruiu, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D50023?vs=158112&id=158331#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50023
Files:
lld/trunk/COFF/ICF.cpp
lld/trunk/ELF/ICF.cpp
llvm/trunk/include/llvm/Support/xxhash.h
llvm/trunk/lib/Support/xxhash.cpp
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: 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 <algorithm>
#include <atomic>
#include <vector>
@@ -65,13 +66,6 @@
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 @@
// 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: 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<uint8_t> Data) {
+ return xxHash64({(const char *)Data.data(), Data.size()});
+}
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<uint8_t> Data);
}
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50023.158331.patch
Type: text/x-patch
Size: 2571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180731/7da4d183/attachment.bin>
More information about the llvm-commits
mailing list