[lld] 4c98d08 - [ELF] Speed up MergeInputSection::split*. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 16 21:17:09 PST 2021
Author: Fangrui Song
Date: 2021-12-16T21:17:02-08:00
New Revision: 4c98d08841e65f2a61382ecd9f06b0d01ffd615a
URL: https://github.com/llvm/llvm-project/commit/4c98d08841e65f2a61382ecd9f06b0d01ffd615a
DIFF: https://github.com/llvm/llvm-project/commit/4c98d08841e65f2a61382ecd9f06b0d01ffd615a.diff
LOG: [ELF] Speed up MergeInputSection::split*. NFC
Added:
Modified:
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index b2f63799337e..baceaa780c6e 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -1365,7 +1365,7 @@ SyntheticSection *MergeInputSection::getParent() const {
// null-terminated strings.
void MergeInputSection::splitStrings(ArrayRef<uint8_t> data, size_t entSize) {
size_t off = 0;
- bool isAlloc = flags & SHF_ALLOC;
+ const bool live = !(flags & SHF_ALLOC) || !config->gcSections;
StringRef s = toStringRef(data);
while (!s.empty()) {
@@ -1374,7 +1374,7 @@ void MergeInputSection::splitStrings(ArrayRef<uint8_t> data, size_t entSize) {
fatal(toString(this) + ": string is not null terminated");
size_t size = end + entSize;
- pieces.emplace_back(off, xxHash64(s.substr(0, size)), !isAlloc);
+ pieces.emplace_back(off, xxHash64(s.substr(0, size)), live);
s = s.substr(size);
off += size;
}
@@ -1386,10 +1386,10 @@ void MergeInputSection::splitNonStrings(ArrayRef<uint8_t> data,
size_t entSize) {
size_t size = data.size();
assert((size % entSize) == 0);
- bool isAlloc = flags & SHF_ALLOC;
+ const bool live = !(flags & SHF_ALLOC) || !config->gcSections;
for (size_t i = 0; i != size; i += entSize)
- pieces.emplace_back(i, xxHash64(data.slice(i, entSize)), !isAlloc);
+ pieces.emplace_back(i, xxHash64(data.slice(i, entSize)), live);
}
template <class ELFT>
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index 70bbe4975a38..a5967b500f90 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -250,7 +250,7 @@ class InputSectionBase : public SectionBase {
// be found by looking at the next one).
struct SectionPiece {
SectionPiece(size_t off, uint32_t hash, bool live)
- : inputOff(off), live(live || !config->gcSections), hash(hash >> 1) {}
+ : inputOff(off), live(live), hash(hash >> 1) {}
uint32_t inputOff;
uint32_t live : 1;
More information about the llvm-commits
mailing list