Skip to content

Commit fb70282

Browse files
authored
[MC] Move some bool members to MCFragment. NFC
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 ``` Pull Request: llvm#100976
1 parent 2c376fe commit fb70282

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

llvm/include/llvm/MC/MCFragment.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,15 @@ class MCFragment {
6969
FragmentType Kind;
7070

7171
protected:
72+
/// Used by subclasses for better packing.
73+
///
74+
/// MCEncodedFragment
7275
bool HasInstructions : 1;
76+
bool AlignToBundleEnd : 1;
77+
/// MCDataFragment
7378
bool LinkerRelaxable : 1;
79+
/// MCRelaxableFragment: x86-specific
80+
bool AllowAutoPadding : 1;
7481

7582
MCFragment(FragmentType Kind, bool HasInstructions);
7683

@@ -115,9 +122,6 @@ class MCDummyFragment : public MCFragment {
115122
/// data.
116123
///
117124
class MCEncodedFragment : public MCFragment {
118-
/// Should this fragment be aligned to the end of a bundle?
119-
bool AlignToBundleEnd = false;
120-
121125
uint8_t BundlePadding = 0;
122126

123127
protected:
@@ -228,11 +232,8 @@ class MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> {
228232
/// relaxed during the assembler layout and relaxation stage.
229233
///
230234
class MCRelaxableFragment : public MCEncodedFragmentWithFixups<8, 1> {
231-
232235
/// The instruction this is a fragment for.
233236
MCInst Inst;
234-
/// Can we auto pad the instruction?
235-
bool AllowAutoPadding = false;
236237

237238
public:
238239
MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI)

llvm/lib/MC/MCFragment.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
using namespace llvm;
2828

2929
MCFragment::MCFragment(FragmentType Kind, bool HasInstructions)
30-
: Kind(Kind), HasInstructions(HasInstructions), LinkerRelaxable(false) {}
30+
: Kind(Kind), HasInstructions(HasInstructions), AlignToBundleEnd(false),
31+
LinkerRelaxable(false), AllowAutoPadding(false) {}
3132

3233
void MCFragment::destroy() {
3334
switch (Kind) {

0 commit comments

Comments
 (0)