Skip to content

Commit 66f0984

Browse files
authored
Reorder fields for better packing (#77998)
The RelocationEntry's fields are poorly ordered when considering padding. This reordering reduces the size from 56 bytes to 40 bytes (on LP64).
1 parent 3149c93 commit 66f0984

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,22 @@ class SectionEntry {
116116
/// linker.
117117
class RelocationEntry {
118118
public:
119-
/// SectionID - the section this relocation points to.
120-
unsigned SectionID;
121-
122119
/// Offset - offset into the section.
123120
uint64_t Offset;
124121

125-
/// RelType - relocation type.
126-
uint32_t RelType;
127-
128122
/// Addend - the relocation addend encoded in the instruction itself. Also
129123
/// used to make a relocation section relative instead of symbol relative.
130124
int64_t Addend;
131125

126+
/// SectionID - the section this relocation points to.
127+
unsigned SectionID;
128+
129+
/// RelType - relocation type.
130+
uint32_t RelType;
131+
132132
struct SectionPair {
133-
uint32_t SectionA;
134-
uint32_t SectionB;
133+
uint32_t SectionA;
134+
uint32_t SectionB;
135135
};
136136

137137
/// SymOffset - Section offset of the relocation entry's symbol (used for GOT
@@ -141,36 +141,36 @@ class RelocationEntry {
141141
SectionPair Sections;
142142
};
143143

144-
/// True if this is a PCRel relocation (MachO specific).
145-
bool IsPCRel;
146-
147144
/// The size of this relocation (MachO specific).
148145
unsigned Size;
149146

147+
/// True if this is a PCRel relocation (MachO specific).
148+
bool IsPCRel : 1;
149+
150150
// ARM (MachO and COFF) specific.
151-
bool IsTargetThumbFunc = false;
151+
bool IsTargetThumbFunc : 1;
152152

153153
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend)
154-
: SectionID(id), Offset(offset), RelType(type), Addend(addend),
155-
SymOffset(0), IsPCRel(false), Size(0), IsTargetThumbFunc(false) {}
154+
: Offset(offset), Addend(addend), SectionID(id), RelType(type),
155+
SymOffset(0), Size(0), IsPCRel(false), IsTargetThumbFunc(false) {}
156156

157157
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend,
158158
uint64_t symoffset)
159-
: SectionID(id), Offset(offset), RelType(type), Addend(addend),
160-
SymOffset(symoffset), IsPCRel(false), Size(0),
159+
: Offset(offset), Addend(addend), SectionID(id), RelType(type),
160+
SymOffset(symoffset), Size(0), IsPCRel(false),
161161
IsTargetThumbFunc(false) {}
162162

163163
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend,
164164
bool IsPCRel, unsigned Size)
165-
: SectionID(id), Offset(offset), RelType(type), Addend(addend),
166-
SymOffset(0), IsPCRel(IsPCRel), Size(Size), IsTargetThumbFunc(false) {}
165+
: Offset(offset), Addend(addend), SectionID(id), RelType(type),
166+
SymOffset(0), Size(Size), IsPCRel(IsPCRel), IsTargetThumbFunc(false) {}
167167

168168
RelocationEntry(unsigned id, uint64_t offset, uint32_t type, int64_t addend,
169169
unsigned SectionA, uint64_t SectionAOffset, unsigned SectionB,
170170
uint64_t SectionBOffset, bool IsPCRel, unsigned Size)
171-
: SectionID(id), Offset(offset), RelType(type),
172-
Addend(SectionAOffset - SectionBOffset + addend), IsPCRel(IsPCRel),
173-
Size(Size), IsTargetThumbFunc(false) {
171+
: Offset(offset), Addend(SectionAOffset - SectionBOffset + addend),
172+
SectionID(id), RelType(type), Size(Size), IsPCRel(IsPCRel),
173+
IsTargetThumbFunc(false) {
174174
Sections.SectionA = SectionA;
175175
Sections.SectionB = SectionB;
176176
}
@@ -179,9 +179,9 @@ class RelocationEntry {
179179
unsigned SectionA, uint64_t SectionAOffset, unsigned SectionB,
180180
uint64_t SectionBOffset, bool IsPCRel, unsigned Size,
181181
bool IsTargetThumbFunc)
182-
: SectionID(id), Offset(offset), RelType(type),
183-
Addend(SectionAOffset - SectionBOffset + addend), IsPCRel(IsPCRel),
184-
Size(Size), IsTargetThumbFunc(IsTargetThumbFunc) {
182+
: Offset(offset), Addend(SectionAOffset - SectionBOffset + addend),
183+
SectionID(id), RelType(type), Size(Size), IsPCRel(IsPCRel),
184+
IsTargetThumbFunc(IsTargetThumbFunc) {
185185
Sections.SectionA = SectionA;
186186
Sections.SectionB = SectionB;
187187
}

0 commit comments

Comments
 (0)