[PATCH] D50023: Make ICF output deterministic.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 30 15:41:27 PDT 2018
ruiu created this revision.
ruiu added a reviewer: pcc.
Herald added subscribers: mgrang, hiraditya, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: espindola.
This patch does the same thing as r338153 for COFF.
https://reviews.llvm.org/D50023
Files:
lld/COFF/ICF.cpp
lld/ELF/ICF.cpp
llvm/include/llvm/Support/xxhash.h
llvm/lib/Support/xxhash.cpp
Index: llvm/lib/Support/xxhash.cpp
===================================================================
--- llvm/lib/Support/xxhash.cpp
+++ llvm/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/include/llvm/Support/xxhash.h
===================================================================
--- llvm/include/llvm/Support/xxhash.h
+++ 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
Index: lld/ELF/ICF.cpp
===================================================================
--- lld/ELF/ICF.cpp
+++ lld/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/COFF/ICF.cpp
===================================================================
--- lld/COFF/ICF.cpp
+++ 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 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50023.158112.patch
Type: text/x-patch
Size: 2499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180730/ec232d17/attachment.bin>
More information about the llvm-commits
mailing list