[llvm] [MC] Move some bool members to MCFragment. NFC (PR #100976)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 28 23:24:53 PDT 2024
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/100976
Move `AllowAutoPadding` to MCFragment, which reduce the
MCRelaxableFragment size by 8 bytes. While here, also move
`AlignToBundleEnd` next to `HasInstructions`. Functions that create
fragments are slightly shorter due to fewer byte zeroing instructions.
Although fewer in number than MCDataFragments, MCRelaxableFragment
objects still constitute a significant proportion warranting
optimization.
```
% clang -c sqlite3.i -w -g -Xclang -print-stats
...
2206 assembler - Number of emitted assembler fragments - align
83980 assembler - Number of emitted assembler fragments - data
84 assembler - Number of emitted assembler fragments - fill
169462 assembler - Number of emitted assembler fragments - total
11396 assembler - Number of emitted assembler fragments - relaxable
```
>From 97082c5dc407ba29973a37116a69e3a3549f9354 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Sun, 28 Jul 2024 23:24:43 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5-bogner
---
llvm/include/llvm/MC/MCFragment.h | 13 +++++++------
llvm/lib/MC/MCFragment.cpp | 3 ++-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h
index 84f8e060320a1..bfd349e8b8e7e 100644
--- a/llvm/include/llvm/MC/MCFragment.h
+++ b/llvm/include/llvm/MC/MCFragment.h
@@ -69,8 +69,15 @@ class MCFragment {
FragmentType Kind;
protected:
+ /// Used by subclasses for better packing.
+ ///
+ /// MCEncodedFragment
bool HasInstructions : 1;
+ bool AlignToBundleEnd : 1;
+ /// MCDataFragment
bool LinkerRelaxable : 1;
+ /// MCRelaxableFragment: x86-specific
+ bool AllowAutoPadding : 1;
MCFragment(FragmentType Kind, bool HasInstructions);
@@ -115,9 +122,6 @@ class MCDummyFragment : public MCFragment {
/// data.
///
class MCEncodedFragment : public MCFragment {
- /// Should this fragment be aligned to the end of a bundle?
- bool AlignToBundleEnd = false;
-
uint8_t BundlePadding = 0;
protected:
@@ -228,11 +232,8 @@ class MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> {
/// relaxed during the assembler layout and relaxation stage.
///
class MCRelaxableFragment : public MCEncodedFragmentWithFixups<8, 1> {
-
/// The instruction this is a fragment for.
MCInst Inst;
- /// Can we auto pad the instruction?
- bool AllowAutoPadding = false;
public:
MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI)
diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp
index 3086730b1be8a..ac1b5a8fb8274 100644
--- a/llvm/lib/MC/MCFragment.cpp
+++ b/llvm/lib/MC/MCFragment.cpp
@@ -27,7 +27,8 @@
using namespace llvm;
MCFragment::MCFragment(FragmentType Kind, bool HasInstructions)
- : Kind(Kind), HasInstructions(HasInstructions), LinkerRelaxable(false) {}
+ : Kind(Kind), HasInstructions(HasInstructions), AlignToBundleEnd(false),
+ LinkerRelaxable(false), AllowAutoPadding(false) {}
void MCFragment::destroy() {
switch (Kind) {
More information about the llvm-commits
mailing list