forked from OSchip/llvm-project
[ELF] Make InputSection smaller
On LP64/Windows platforms, this decreases sizeof(InputSection) from 208 (larger on Windows) to 184. For a large executable (7.6GiB, inputSections.size()=5105122, make<InputSection> called 4835760 times), this decreases cgroup memory.max_usage_in_bytes by 0.6% Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D91018
This commit is contained in:
parent
9c098d37f4
commit
2eccde4a2b
|
@ -52,15 +52,15 @@ public:
|
||||||
// this but instead this->Repl.
|
// this but instead this->Repl.
|
||||||
SectionBase *repl;
|
SectionBase *repl;
|
||||||
|
|
||||||
unsigned sectionKind : 3;
|
uint8_t sectionKind : 3;
|
||||||
|
|
||||||
// The next two bit fields are only used by InputSectionBase, but we
|
// The next two bit fields are only used by InputSectionBase, but we
|
||||||
// put them here so the struct packs better.
|
// put them here so the struct packs better.
|
||||||
|
|
||||||
unsigned bss : 1;
|
uint8_t bss : 1;
|
||||||
|
|
||||||
// Set for sections that should not be folded by ICF.
|
// Set for sections that should not be folded by ICF.
|
||||||
unsigned keepUnique : 1;
|
uint8_t keepUnique : 1;
|
||||||
|
|
||||||
// The 1-indexed partition that this section is assigned to by the garbage
|
// 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
|
// collector, or 0 if this section is dead. Normally there is only one
|
||||||
|
@ -134,6 +134,10 @@ public:
|
||||||
// and shrinking a section.
|
// and shrinking a section.
|
||||||
unsigned bytesDropped = 0;
|
unsigned bytesDropped = 0;
|
||||||
|
|
||||||
|
// Whether the section needs to be padded with a NOP filler due to
|
||||||
|
// deleteFallThruJmpInsn.
|
||||||
|
bool nopFiller = false;
|
||||||
|
|
||||||
void drop_back(uint64_t num) { bytesDropped += num; }
|
void drop_back(uint64_t num) { bytesDropped += num; }
|
||||||
|
|
||||||
void push_back(uint64_t num) {
|
void push_back(uint64_t num) {
|
||||||
|
@ -210,17 +214,13 @@ public:
|
||||||
// The native ELF reloc data type is not very convenient to handle.
|
// The native ELF reloc data type is not very convenient to handle.
|
||||||
// So we convert ELF reloc records to our own records in Relocations.cpp.
|
// So we convert ELF reloc records to our own records in Relocations.cpp.
|
||||||
// This vector contains such "cooked" relocations.
|
// This vector contains such "cooked" relocations.
|
||||||
std::vector<Relocation> relocations;
|
SmallVector<Relocation, 0> relocations;
|
||||||
|
|
||||||
// Indicates that this section needs to be padded with a NOP filler if set to
|
|
||||||
// true.
|
|
||||||
bool nopFiller = false;
|
|
||||||
|
|
||||||
// These are modifiers to jump instructions that are necessary when basic
|
// These are modifiers to jump instructions that are necessary when basic
|
||||||
// block sections are enabled. Basic block sections creates opportunities to
|
// block sections are enabled. Basic block sections creates opportunities to
|
||||||
// relax jump instructions at basic block boundaries after reordering the
|
// relax jump instructions at basic block boundaries after reordering the
|
||||||
// basic blocks.
|
// basic blocks.
|
||||||
std::vector<JumpInstrMod> jumpInstrMods;
|
SmallVector<JumpInstrMod, 0> jumpInstrMods;
|
||||||
|
|
||||||
// A function compiled with -fsplit-stack calling a function
|
// A function compiled with -fsplit-stack calling a function
|
||||||
// compiled without -fsplit-stack needs its prologue adjusted. Find
|
// compiled without -fsplit-stack needs its prologue adjusted. Find
|
||||||
|
@ -390,6 +390,8 @@ private:
|
||||||
template <class ELFT> void copyShtGroup(uint8_t *buf);
|
template <class ELFT> void copyShtGroup(uint8_t *buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(InputSection) <= 184, "InputSection is too big");
|
||||||
|
|
||||||
inline bool isDebugSection(const InputSectionBase &sec) {
|
inline bool isDebugSection(const InputSectionBase &sec) {
|
||||||
return sec.name.startswith(".debug") || sec.name.startswith(".zdebug");
|
return sec.name.startswith(".debug") || sec.name.startswith(".zdebug");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue