Skip to content

Commit 898b6c5

Browse files
committed
[ELF] Shuffle SectionBase fields. NFC
Move frequently used fields (e.g. sectionKind, partition) to the top. My x86-64 lld executable is 600+B smaller.
1 parent ad485b7 commit 898b6c5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lld/ELF/InputSection.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ class SectionBase {
5050

5151
Kind kind() const { return (Kind)sectionKind; }
5252

53-
StringRef name;
54-
5553
uint8_t sectionKind : 3;
5654

5755
// The next two bit fields are only used by InputSectionBase, but we
@@ -62,17 +60,19 @@ class SectionBase {
6260
// Set for sections that should not be folded by ICF.
6361
uint8_t keepUnique : 1;
6462

63+
uint8_t partition = 1;
64+
uint32_t type;
65+
StringRef name;
66+
6567
// The 1-indexed partition that this section is assigned to by the garbage
6668
// collector, or 0 if this section is dead. Normally there is only one
6769
// partition, so this will either be 0 or 1.
68-
uint8_t partition = 1;
6970
elf::Partition &getPartition() const;
7071

7172
// These corresponds to the fields in Elf_Shdr.
72-
uint32_t alignment;
7373
uint64_t flags;
74+
uint32_t alignment;
7475
uint32_t entsize;
75-
uint32_t type;
7676
uint32_t link;
7777
uint32_t info;
7878

@@ -95,8 +95,8 @@ class SectionBase {
9595
constexpr SectionBase(Kind sectionKind, StringRef name, uint64_t flags,
9696
uint32_t entsize, uint32_t alignment, uint32_t type,
9797
uint32_t info, uint32_t link)
98-
: name(name), sectionKind(sectionKind), bss(false), keepUnique(false),
99-
alignment(alignment), flags(flags), entsize(entsize), type(type),
98+
: sectionKind(sectionKind), bss(false), keepUnique(false), type(type),
99+
name(name), flags(flags), alignment(alignment), entsize(entsize),
100100
link(link), info(info) {}
101101
};
102102

0 commit comments

Comments
 (0)