[llvm] 806a2b1 - [MC] Reorder MCFragment members to decrease padding
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 5 19:09:46 PST 2020
Author: Fangrui Song
Date: 2020-01-05T19:09:40-08:00
New Revision: 806a2b1f3d8850eb88f1f9338e86b6398841c961
URL: https://github.com/llvm/llvm-project/commit/806a2b1f3d8850eb88f1f9338e86b6398841c961
DIFF: https://github.com/llvm/llvm-project/commit/806a2b1f3d8850eb88f1f9338e86b6398841c961.diff
LOG: [MC] Reorder MCFragment members to decrease padding
sizeof(MCFragment) does not change, but some if its subclasses do, e.g.
on a 64-bit platform,
sizeof(MCEncodedFragment) decreases from 64 to 56,
sizeof(MCDataFragment) decreases from 224 to 216.
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 1ecbdbfa9806..4722e9b2fa2b 100644
--- a/llvm/include/llvm/MC/MCFragment.h
+++ b/llvm/include/llvm/MC/MCFragment.h
@@ -50,33 +50,24 @@ class MCFragment : public ilist_node_with_parent<MCFragment, MCSection> {
};
private:
- FragmentType Kind;
-
-protected:
- bool HasInstructions;
-
-private:
- /// The layout order of this fragment.
- unsigned LayoutOrder;
-
/// The data for the section this fragment is in.
MCSection *Parent;
/// The atom this fragment is in, as represented by its defining symbol.
const MCSymbol *Atom;
- /// \name Assembler Backend Data
- /// @{
- //
- // FIXME: This could all be kept private to the assembler implementation.
-
/// The offset of this fragment in its section. This is ~0 until
/// initialized.
uint64_t Offset;
- /// @}
+ /// The layout order of this fragment.
+ unsigned LayoutOrder;
+
+ FragmentType Kind;
protected:
+ bool HasInstructions;
+
MCFragment(FragmentType Kind, bool HasInstructions,
MCSection *Parent = nullptr);
diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp
index f6b64c8fa95d..a96b8e86aed3 100644
--- a/llvm/lib/MC/MCFragment.cpp
+++ b/llvm/lib/MC/MCFragment.cpp
@@ -234,8 +234,8 @@ void ilist_alloc_traits<MCFragment>::deleteNode(MCFragment *V) { V->destroy(); }
MCFragment::MCFragment(FragmentType Kind, bool HasInstructions,
MCSection *Parent)
- : Kind(Kind), HasInstructions(HasInstructions), LayoutOrder(0),
- Parent(Parent), Atom(nullptr), Offset(~UINT64_C(0)) {
+ : Parent(Parent), Atom(nullptr), Offset(~UINT64_C(0)), LayoutOrder(0),
+ Kind(Kind), HasInstructions(HasInstructions) {
if (Parent && !isa<MCDummyFragment>(*this))
Parent->getFragmentList().push_back(this);
}
More information about the llvm-commits
mailing list