[llvm] 9b44cfb - [MC] Remove unused section parameters from MCFragment constructors
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 21 22:57:17 PDT 2024
Author: Fangrui Song
Date: 2024-06-21T22:57:12-07:00
New Revision: 9b44cfbdbf694e29d80bea688f3ecbfd1d764bfd
URL: https://github.com/llvm/llvm-project/commit/9b44cfbdbf694e29d80bea688f3ecbfd1d764bfd
DIFF: https://github.com/llvm/llvm-project/commit/9b44cfbdbf694e29d80bea688f3ecbfd1d764bfd.diff
LOG: [MC] Remove unused section parameters from MCFragment constructors
Added:
Modified:
llvm/include/llvm/MC/MCFragment.h
llvm/lib/MC/MCFragment.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h
index dbf309cc5383d..e7675481610f4 100644
--- a/llvm/include/llvm/MC/MCFragment.h
+++ b/llvm/include/llvm/MC/MCFragment.h
@@ -72,8 +72,7 @@ class MCFragment {
bool HasInstructions : 1;
bool LinkerRelaxable : 1;
- MCFragment(FragmentType Kind, bool HasInstructions,
- MCSection *Parent = nullptr);
+ MCFragment(FragmentType Kind, bool HasInstructions);
public:
MCFragment() = delete;
@@ -122,9 +121,8 @@ class MCEncodedFragment : public MCFragment {
uint8_t BundlePadding = 0;
protected:
- MCEncodedFragment(MCFragment::FragmentType FType, bool HasInstructions,
- MCSection *Sec)
- : MCFragment(FType, HasInstructions, Sec) {}
+ MCEncodedFragment(MCFragment::FragmentType FType, bool HasInstructions)
+ : MCFragment(FType, HasInstructions) {}
/// The MCSubtargetInfo in effect when the instruction was encoded.
/// It must be non-null for instructions.
@@ -182,9 +180,8 @@ class MCEncodedFragmentWithContents : public MCEncodedFragment {
protected:
MCEncodedFragmentWithContents(MCFragment::FragmentType FType,
- bool HasInstructions,
- MCSection *Sec)
- : MCEncodedFragment(FType, HasInstructions, Sec) {}
+ bool HasInstructions)
+ : MCEncodedFragment(FType, HasInstructions) {}
public:
SmallVectorImpl<char> &getContents() { return Contents; }
@@ -203,10 +200,8 @@ class MCEncodedFragmentWithFixups :
protected:
MCEncodedFragmentWithFixups(MCFragment::FragmentType FType,
- bool HasInstructions,
- MCSection *Sec)
- : MCEncodedFragmentWithContents<ContentsSize>(FType, HasInstructions,
- Sec) {}
+ bool HasInstructions)
+ : MCEncodedFragmentWithContents<ContentsSize>(FType, HasInstructions) {}
public:
@@ -234,8 +229,7 @@ class MCEncodedFragmentWithFixups :
///
class MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> {
public:
- MCDataFragment(MCSection *Sec = nullptr)
- : MCEncodedFragmentWithFixups<32, 4>(FT_Data, false, Sec) {}
+ MCDataFragment() : MCEncodedFragmentWithFixups<32, 4>(FT_Data, false) {}
static bool classof(const MCFragment *F) {
return F->getKind() == MCFragment::FT_Data;
@@ -252,9 +246,8 @@ class MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> {
///
class MCCompactEncodedInstFragment : public MCEncodedFragmentWithContents<4> {
public:
- MCCompactEncodedInstFragment(MCSection *Sec = nullptr)
- : MCEncodedFragmentWithContents(FT_CompactEncodedInst, true, Sec) {
- }
+ MCCompactEncodedInstFragment()
+ : MCEncodedFragmentWithContents(FT_CompactEncodedInst, true) {}
static bool classof(const MCFragment *F) {
return F->getKind() == MCFragment::FT_CompactEncodedInst;
@@ -272,10 +265,10 @@ class MCRelaxableFragment : public MCEncodedFragmentWithFixups<8, 1> {
bool AllowAutoPadding = false;
public:
- MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI,
- MCSection *Sec = nullptr)
- : MCEncodedFragmentWithFixups(FT_Relaxable, true, Sec),
- Inst(Inst) { this->STI = &STI; }
+ MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI)
+ : MCEncodedFragmentWithFixups(FT_Relaxable, true), Inst(Inst) {
+ this->STI = &STI;
+ }
const MCInst &getInst() const { return Inst; }
void setInst(const MCInst &Value) { Inst = Value; }
@@ -312,8 +305,8 @@ class MCAlignFragment : public MCFragment {
public:
MCAlignFragment(Align Alignment, int64_t Value, unsigned ValueSize,
- unsigned MaxBytesToEmit, MCSection *Sec = nullptr)
- : MCFragment(FT_Align, false, Sec), Alignment(Alignment), EmitNops(false),
+ unsigned MaxBytesToEmit)
+ : MCFragment(FT_Align, false), Alignment(Alignment), EmitNops(false),
Value(Value), ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit) {}
Align getAlignment() const { return Alignment; }
@@ -349,8 +342,8 @@ class MCFillFragment : public MCFragment {
public:
MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues,
- SMLoc Loc, MCSection *Sec = nullptr)
- : MCFragment(FT_Fill, false, Sec), ValueSize(VSize), Value(Value),
+ SMLoc Loc)
+ : MCFragment(FT_Fill, false), ValueSize(VSize), Value(Value),
NumValues(NumValues), Loc(Loc) {}
uint64_t getValue() const { return Value; }
@@ -378,8 +371,8 @@ class MCNopsFragment : public MCFragment {
public:
MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L,
- const MCSubtargetInfo &STI, MCSection *Sec = nullptr)
- : MCFragment(FT_Nops, false, Sec), Size(NumBytes),
+ const MCSubtargetInfo &STI)
+ : MCFragment(FT_Nops, false), Size(NumBytes),
ControlledNopLength(ControlledNopLength), Loc(L), STI(STI) {}
int64_t getNumBytes() const { return Size; }
@@ -405,10 +398,8 @@ class MCOrgFragment : public MCFragment {
SMLoc Loc;
public:
- MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc,
- MCSection *Sec = nullptr)
- : MCFragment(FT_Org, false, Sec), Value(Value), Offset(&Offset),
- Loc(Loc) {}
+ MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
+ : MCFragment(FT_Org, false), Value(Value), Offset(&Offset), Loc(Loc) {}
const MCExpr &getOffset() const { return *Offset; }
@@ -429,9 +420,9 @@ class MCLEBFragment final : public MCEncodedFragmentWithFixups<8, 0> {
const MCExpr *Value;
public:
- MCLEBFragment(const MCExpr &Value, bool IsSigned, MCSection *Sec = nullptr)
- : MCEncodedFragmentWithFixups<8, 0>(FT_LEB, false, Sec),
- IsSigned(IsSigned), Value(&Value) {
+ MCLEBFragment(const MCExpr &Value, bool IsSigned)
+ : MCEncodedFragmentWithFixups<8, 0>(FT_LEB, false), IsSigned(IsSigned),
+ Value(&Value) {
getContents().push_back(0);
}
@@ -457,9 +448,8 @@ class MCDwarfLineAddrFragment : public MCEncodedFragmentWithFixups<8, 1> {
const MCExpr *AddrDelta;
public:
- MCDwarfLineAddrFragment(int64_t LineDelta, const MCExpr &AddrDelta,
- MCSection *Sec = nullptr)
- : MCEncodedFragmentWithFixups<8, 1>(FT_Dwarf, false, Sec),
+ MCDwarfLineAddrFragment(int64_t LineDelta, const MCExpr &AddrDelta)
+ : MCEncodedFragmentWithFixups<8, 1>(FT_Dwarf, false),
LineDelta(LineDelta), AddrDelta(&AddrDelta) {}
int64_t getLineDelta() const { return LineDelta; }
@@ -477,8 +467,8 @@ class MCDwarfCallFrameFragment : public MCEncodedFragmentWithFixups<8, 1> {
const MCExpr *AddrDelta;
public:
- MCDwarfCallFrameFragment(const MCExpr &AddrDelta, MCSection *Sec = nullptr)
- : MCEncodedFragmentWithFixups<8, 1>(FT_DwarfFrame, false, Sec),
+ MCDwarfCallFrameFragment(const MCExpr &AddrDelta)
+ : MCEncodedFragmentWithFixups<8, 1>(FT_DwarfFrame, false),
AddrDelta(&AddrDelta) {}
const MCExpr &getAddrDelta() const { return *AddrDelta; }
@@ -494,8 +484,8 @@ class MCSymbolIdFragment : public MCFragment {
const MCSymbol *Sym;
public:
- MCSymbolIdFragment(const MCSymbol *Sym, MCSection *Sec = nullptr)
- : MCFragment(FT_SymbolId, false, Sec), Sym(Sym) {}
+ MCSymbolIdFragment(const MCSymbol *Sym)
+ : MCFragment(FT_SymbolId, false), Sym(Sym) {}
const MCSymbol *getSymbol() { return Sym; }
const MCSymbol *getSymbol() const { return Sym; }
@@ -522,9 +512,8 @@ class MCCVInlineLineTableFragment : public MCFragment {
public:
MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId,
unsigned StartLineNum, const MCSymbol *FnStartSym,
- const MCSymbol *FnEndSym,
- MCSection *Sec = nullptr)
- : MCFragment(FT_CVInlineLines, false, Sec), SiteFuncId(SiteFuncId),
+ const MCSymbol *FnEndSym)
+ : MCFragment(FT_CVInlineLines, false), SiteFuncId(SiteFuncId),
StartFileId(StartFileId), StartLineNum(StartLineNum),
FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
@@ -551,8 +540,8 @@ class MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> {
public:
MCCVDefRangeFragment(
ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
- StringRef FixedSizePortion, MCSection *Sec = nullptr)
- : MCEncodedFragmentWithFixups<32, 4>(FT_CVDefRange, false, Sec),
+ StringRef FixedSizePortion)
+ : MCEncodedFragmentWithFixups<32, 4>(FT_CVDefRange, false),
Ranges(Ranges.begin(), Ranges.end()),
FixedSizePortion(FixedSizePortion) {}
@@ -583,9 +572,8 @@ class MCBoundaryAlignFragment : public MCFragment {
const MCSubtargetInfo &STI;
public:
- MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI,
- MCSection *Sec = nullptr)
- : MCFragment(FT_BoundaryAlign, false, Sec), AlignBoundary(AlignBoundary),
+ MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI)
+ : MCFragment(FT_BoundaryAlign, false), AlignBoundary(AlignBoundary),
STI(STI) {}
uint64_t getSize() const { return Size; }
@@ -613,8 +601,8 @@ class MCPseudoProbeAddrFragment : public MCEncodedFragmentWithFixups<8, 1> {
const MCExpr *AddrDelta;
public:
- MCPseudoProbeAddrFragment(const MCExpr *AddrDelta, MCSection *Sec = nullptr)
- : MCEncodedFragmentWithFixups<8, 1>(FT_PseudoProbe, false, Sec),
+ MCPseudoProbeAddrFragment(const MCExpr *AddrDelta)
+ : MCEncodedFragmentWithFixups<8, 1>(FT_PseudoProbe, false),
AddrDelta(AddrDelta) {}
const MCExpr &getAddrDelta() const { return *AddrDelta; }
diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp
index 0d8d639b0f8af..ea5bf7b58cdb8 100644
--- a/llvm/lib/MC/MCFragment.cpp
+++ b/llvm/lib/MC/MCFragment.cpp
@@ -198,13 +198,9 @@ uint64_t llvm::computeBundlePadding(const MCAssembler &Assembler,
/* *** */
-MCFragment::MCFragment(FragmentType Kind, bool HasInstructions,
- MCSection *Parent)
+MCFragment::MCFragment(FragmentType Kind, bool HasInstructions)
: Parent(Parent), Kind(Kind), HasInstructions(HasInstructions),
- LinkerRelaxable(false) {
- if (Parent && !isa<MCDummyFragment>(*this))
- Parent->addFragment(*this);
-}
+ LinkerRelaxable(false) {}
void MCFragment::destroy() {
// First check if we are the sentinel.
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 6022c47f1220e..9b63062e3073e 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -196,8 +196,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const *Symbol) {
getAssembler().registerSection(*SXData);
SXData->ensureMinAlignment(Align(4));
- getContext().allocFragment<MCSymbolIdFragment>(Symbol, SXData);
-
+ insert(getContext().allocFragment<MCSymbolIdFragment>(Symbol));
getAssembler().registerSymbol(*Symbol);
CSymbol->setIsSafeSEH();
More information about the llvm-commits
mailing list