Skip to content

Commit d9dfe75

Browse files
committed
MCNopsFragment,MCBoundaryAlignFragment: Use parent MCSubtargetInfo
1 parent fbf74b2 commit d9dfe75

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

llvm/include/llvm/MC/MCSection.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ class MCFragment {
107107
uint32_t VarContentEnd = 0;
108108
uint32_t VarFixupStart = 0;
109109

110+
protected:
110111
const MCSubtargetInfo *STI = nullptr;
111112

113+
private:
112114
// Optional variable-size tail used by various fragment types.
113115
union Tail {
114116
struct {
@@ -362,22 +364,19 @@ class MCNopsFragment : public MCFragment {
362364
/// Source location of the directive that this fragment was created for.
363365
SMLoc Loc;
364366

365-
/// When emitting Nops some subtargets have specific nop encodings.
366-
const MCSubtargetInfo &STI;
367-
368367
public:
369368
MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L,
370369
const MCSubtargetInfo &STI)
371370
: MCFragment(FT_Nops), Size(NumBytes),
372-
ControlledNopLength(ControlledNopLength), Loc(L), STI(STI) {}
371+
ControlledNopLength(ControlledNopLength), Loc(L) {
372+
this->STI = &STI;
373+
}
373374

374375
int64_t getNumBytes() const { return Size; }
375376
int64_t getControlledNopLength() const { return ControlledNopLength; }
376377

377378
SMLoc getLoc() const { return Loc; }
378379

379-
const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
380-
381380
static bool classof(const MCFragment *F) {
382381
return F->getKind() == MCFragment::FT_Nops;
383382
}
@@ -490,12 +489,11 @@ class MCBoundaryAlignFragment : public MCFragment {
490489
/// is not meaningful before that.
491490
uint64_t Size = 0;
492491

493-
/// When emitting Nops some subtargets have specific nop encodings.
494-
const MCSubtargetInfo &STI;
495-
496492
public:
497493
MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI)
498-
: MCFragment(FT_BoundaryAlign), AlignBoundary(AlignBoundary), STI(STI) {}
494+
: MCFragment(FT_BoundaryAlign), AlignBoundary(AlignBoundary) {
495+
this->STI = &STI;
496+
}
499497

500498
uint64_t getSize() const { return Size; }
501499
void setSize(uint64_t Value) { Size = Value; }
@@ -509,8 +507,6 @@ class MCBoundaryAlignFragment : public MCFragment {
509507
LastFragment = F;
510508
}
511509

512-
const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
513-
514510
static bool classof(const MCFragment *F) {
515511
return F->getKind() == MCFragment::FT_BoundaryAlign;
516512
}

0 commit comments

Comments
 (0)