[llvm] 846e47e - [MC] Reduce size of MCDataFragment by 8 bytes (#95293)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 03:05:01 PDT 2024
Author: aengelke
Date: 2024-06-13T12:04:56+02:00
New Revision: 846e47e7b880bcf6b8f5773fe0fe236d486f3239
URL: https://github.com/llvm/llvm-project/commit/846e47e7b880bcf6b8f5773fe0fe236d486f3239
DIFF: https://github.com/llvm/llvm-project/commit/846e47e7b880bcf6b8f5773fe0fe236d486f3239.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/MC/MCFragment.h
llvm/lib/MC/MCFragment.cpp
Removed:
################################################################################
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