[lld] 898b6c5 - [ELF] Shuffle SectionBase fields. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 20 13:23:39 PST 2022
Author: Fangrui Song
Date: 2022-11-20T21:23:30Z
New Revision: 898b6c5f3a8c78d9663cf58732baee0c0687451b
URL: https://github.com/llvm/llvm-project/commit/898b6c5f3a8c78d9663cf58732baee0c0687451b
DIFF: https://github.com/llvm/llvm-project/commit/898b6c5f3a8c78d9663cf58732baee0c0687451b.diff
LOG: [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.
Added:
Modified:
lld/ELF/InputSection.h
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index 19915249c5c70..c4caa01265b5b 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -50,8 +50,6 @@ class SectionBase {
Kind kind() const { return (Kind)sectionKind; }
- StringRef name;
-
uint8_t sectionKind : 3;
// The next two bit fields are only used by InputSectionBase, but we
@@ -62,17 +60,19 @@ class SectionBase {
// Set for sections that should not be folded by ICF.
uint8_t keepUnique : 1;
+ uint8_t partition = 1;
+ uint32_t type;
+ StringRef name;
+
// The 1-indexed partition that this section is assigned to by the garbage
// collector, or 0 if this section is dead. Normally there is only one
// partition, so this will either be 0 or 1.
- uint8_t partition = 1;
elf::Partition &getPartition() const;
// These corresponds to the fields in Elf_Shdr.
- uint32_t alignment;
uint64_t flags;
+ uint32_t alignment;
uint32_t entsize;
- uint32_t type;
uint32_t link;
uint32_t info;
@@ -95,8 +95,8 @@ class SectionBase {
constexpr SectionBase(Kind sectionKind, StringRef name, uint64_t flags,
uint32_t entsize, uint32_t alignment, uint32_t type,
uint32_t info, uint32_t link)
- : name(name), sectionKind(sectionKind), bss(false), keepUnique(false),
- alignment(alignment), flags(flags), entsize(entsize), type(type),
+ : sectionKind(sectionKind), bss(false), keepUnique(false), type(type),
+ name(name), flags(flags), alignment(alignment), entsize(entsize),
link(link), info(info) {}
};
More information about the llvm-commits
mailing list