Skip to content

Commit 846e47e

Browse files
authored
[MC] Reduce size of MCDataFragment by 8 bytes (#95293)
Due to alignment, the first two fields of MCEncodedFragment are currently at bytes 40 and 41, so 1 byte over the 8 byte boundary, causing 7 bytes padding to be inserted for the following pointer. Fold two bools of MCFragment into bitfields to reduce move the two fields of MCEncodedFragment one byte earlier to remove the padding bytes. This works, as in the Itanium ABI, there is no padding after base classes. This gives a space reduction of MCDataFragment from 224 to 216 bytes.
1 parent 5c9352e commit 846e47e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

llvm/include/llvm/MC/MCFragment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ class MCFragment {
7272
FragmentType Kind;
7373

7474
protected:
75-
bool HasInstructions;
76-
bool LinkerRelaxable = false;
75+
bool HasInstructions : 1;
76+
bool LinkerRelaxable : 1;
7777

7878
MCFragment(FragmentType Kind, bool HasInstructions,
7979
MCSection *Parent = nullptr);

llvm/lib/MC/MCFragment.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ uint64_t llvm::computeBundlePadding(const MCAssembler &Assembler,
199199

200200
MCFragment::MCFragment(FragmentType Kind, bool HasInstructions,
201201
MCSection *Parent)
202-
: Parent(Parent), Kind(Kind), HasInstructions(HasInstructions) {
202+
: Parent(Parent), Kind(Kind), HasInstructions(HasInstructions),
203+
LinkerRelaxable(false) {
203204
if (Parent && !isa<MCDummyFragment>(*this))
204205
Parent->addFragment(*this);
205206
}

0 commit comments

Comments
 (0)