[llvm] [MC] Reduce size of MCDataFragment by 8 bytes (PR #95293)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 01:21:28 PDT 2024


https://github.com/aengelke updated https://github.com/llvm/llvm-project/pull/95293

>From e034a438b2232651092c37a4e8732e83f35e1631 Mon Sep 17 00:00:00 2001
From: Alexis Engelke <engelke at in.tum.de>
Date: Wed, 12 Jun 2024 19:34:37 +0000
Subject: [PATCH] [MC] Reduce size of MCDataFragment by 8 bytes

Due to alignment, MCFragment was 1 byte over the 8 byte boundary, so
folding to bools into bitfields gives a nice space reduction.
---
 llvm/include/llvm/MC/MCFragment.h | 4 ++--
 llvm/lib/MC/MCFragment.cpp        | 3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h
index ccfe6203514b0..2f62bdb462f83 100644
--- a/llvm/include/llvm/MC/MCFragment.h
+++ b/llvm/include/llvm/MC/MCFragment.h
@@ -72,8 +72,8 @@ class MCFragment {
   FragmentType Kind;
 
 protected:
-  bool HasInstructions;
-  bool LinkerRelaxable = false;
+  bool HasInstructions : 1;
+  bool LinkerRelaxable : 1;
 
   MCFragment(FragmentType Kind, bool HasInstructions,
              MCSection *Parent = nullptr);
diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp
index e911fa21650f4..ffd3a503e733b 100644
--- a/llvm/lib/MC/MCFragment.cpp
+++ b/llvm/lib/MC/MCFragment.cpp
@@ -199,7 +199,8 @@ uint64_t llvm::computeBundlePadding(const MCAssembler &Assembler,
 
 MCFragment::MCFragment(FragmentType Kind, bool HasInstructions,
                        MCSection *Parent)
-    : Parent(Parent), Kind(Kind), HasInstructions(HasInstructions) {
+    : Parent(Parent), Kind(Kind), HasInstructions(HasInstructions),
+      LinkerRelaxable(false) {
   if (Parent && !isa<MCDummyFragment>(*this))
     Parent->addFragment(*this);
 }



More information about the llvm-commits mailing list