[PATCH] D60765: [ELF] Place SectionPiece::{Live,Hash} bit fields together
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 00:44:17 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD358645: [ELF] Place SectionPiece::{Live,Hash} bit fields together (authored by MaskRay, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D60765?vs=195340&id=195682#toc
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60765/new/
https://reviews.llvm.org/D60765
Files:
ELF/InputSection.h
ELF/SyntheticSections.cpp
ELF/SyntheticSections.h
Index: ELF/InputSection.h
===================================================================
--- ELF/InputSection.h
+++ ELF/InputSection.h
@@ -227,13 +227,12 @@
// be found by looking at the next one).
struct SectionPiece {
SectionPiece(size_t Off, uint32_t Hash, bool Live)
- : InputOff(Off), Hash(Hash), OutputOff(0),
- Live(Live || !Config->GcSections) {}
+ : InputOff(Off), Live(Live || !Config->GcSections), Hash(Hash >> 1) {}
uint32_t InputOff;
- uint32_t Hash;
- int64_t OutputOff : 63;
- uint64_t Live : 1;
+ uint32_t Live : 1;
+ uint32_t Hash : 31;
+ uint64_t OutputOff = 0;
};
static_assert(sizeof(SectionPiece) == 16, "SectionPiece is too big");
Index: ELF/SyntheticSections.h
===================================================================
--- ELF/SyntheticSections.h
+++ ELF/SyntheticSections.h
@@ -859,7 +859,8 @@
// If we use lower bits, it significantly increases the probability of
// hash collisons.
size_t getShardId(uint32_t Hash) {
- return Hash >> (32 - llvm::countTrailingZeros(NumShards));
+ assert((Hash >> 31) == 0);
+ return Hash >> (31 - llvm::countTrailingZeros(NumShards));
}
// Section size
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -2876,8 +2876,10 @@
parallelForEachN(0, Concurrency, [&](size_t ThreadId) {
for (MergeInputSection *Sec : Sections) {
for (size_t I = 0, E = Sec->Pieces.size(); I != E; ++I) {
+ if (!Sec->Pieces[I].Live)
+ continue;
size_t ShardId = getShardId(Sec->Pieces[I].Hash);
- if ((ShardId & (Concurrency - 1)) == ThreadId && Sec->Pieces[I].Live)
+ if ((ShardId & (Concurrency - 1)) == ThreadId)
Sec->Pieces[I].OutputOff = Shards[ShardId].add(Sec->getData(I));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60765.195682.patch
Type: text/x-patch
Size: 1887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190418/6b121953/attachment.bin>
More information about the llvm-commits
mailing list