[ELF] Shuffle SectionBase fields. NFC
authorFangrui Song <i@maskray.me>
Sun, 20 Nov 2022 21:23:30 +0000 (21:23 +0000)
committerFangrui Song <i@maskray.me>
Sun, 20 Nov 2022 21:23:30 +0000 (21:23 +0000)
Move frequently used fields (e.g. sectionKind, partition) to the top. My x86-64 lld executable is 600+B smaller.

lld/ELF/InputSection.h

index 1991524..c4caa01 100644 (file)
@@ -50,8 +50,6 @@ public:
 
   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 @@ public:
   // 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 @@ protected:
   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) {}
 };