Skip to content

Commit 87c73f4

Browse files
committed
Move MCSection::printSwitchToSection to MCAsmInfo
This removes the only virtual function of MCSection. NVPTXTargetStreamer::changeSection uses the MCSectionELF print method. Change it to just print the section name.
1 parent 57c7899 commit 87c73f4

27 files changed

+226
-265
lines changed

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class MCStreamer;
3535
class MCSubtargetInfo;
3636
class MCSymbol;
3737
class MCValue;
38+
class Triple;
3839
class raw_ostream;
3940

4041
namespace WinEH {
@@ -485,6 +486,9 @@ class LLVM_ABI MCAsmInfo {
485486
/// syntactically correct.
486487
virtual bool isValidUnquotedName(StringRef Name) const;
487488

489+
virtual void printSwitchToSection(const MCSection &, uint32_t Subsection,
490+
const Triple &, raw_ostream &) const {}
491+
488492
/// Return true if the .section directive should be omitted when
489493
/// emitting \p SectionName. For example:
490494
///

llvm/include/llvm/MC/MCAsmInfoCOFF.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ namespace llvm {
1515

1616
class MCAsmInfoCOFF : public MCAsmInfo {
1717
virtual void anchor();
18+
void printSwitchToSection(const MCSection &, uint32_t, const Triple &,
19+
raw_ostream &) const final;
1820
bool useCodeAlign(const MCSection &Sec) const final;
1921

2022
protected:

llvm/include/llvm/MC/MCAsmInfoDarwin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ namespace llvm {
2121
class MCAsmInfoDarwin : public MCAsmInfo {
2222
public:
2323
explicit MCAsmInfoDarwin();
24+
void printSwitchToSection(const MCSection &, uint32_t, const Triple &,
25+
raw_ostream &) const final;
2426
bool useCodeAlign(const MCSection &Sec) const final;
2527

2628
/// True if the section is atomized using the symbols in it.

llvm/include/llvm/MC/MCAsmInfoELF.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace llvm {
1616
class MCAsmInfoELF : public MCAsmInfo {
1717
virtual void anchor();
1818
MCSection *getNonexecutableStackSection(MCContext &Ctx) const final;
19+
void printSwitchToSection(const MCSection &, uint32_t, const Triple &,
20+
raw_ostream &) const final;
1921
bool useCodeAlign(const MCSection &Sec) const final;
2022

2123
protected:

llvm/include/llvm/MC/MCAsmInfoGOFF.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
namespace llvm {
2121
class MCAsmInfoGOFF : public MCAsmInfo {
22-
virtual void anchor();
22+
void printSwitchToSection(const MCSection &, uint32_t, const Triple &,
23+
raw_ostream &) const final;
2324

2425
protected:
2526
MCAsmInfoGOFF();

llvm/include/llvm/MC/MCAsmInfoWasm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
namespace llvm {
1515
class MCAsmInfoWasm : public MCAsmInfo {
16-
virtual void anchor();
16+
void printSwitchToSection(const MCSection &, uint32_t, const Triple &,
17+
raw_ostream &) const final;
1718

1819
protected:
1920
MCAsmInfoWasm();

llvm/include/llvm/MC/MCAsmInfoXCOFF.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace llvm {
1616
class MCAsmInfoXCOFF : public MCAsmInfo {
1717
protected:
1818
MCAsmInfoXCOFF();
19+
void printSwitchToSection(const MCSection &, uint32_t, const Triple &,
20+
raw_ostream &) const final;
1921
bool useCodeAlign(const MCSection &Sec) const final;
2022

2123
public:

llvm/include/llvm/MC/MCSection.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,6 @@ class LLVM_ABI MCSection {
597597
StringRef Name;
598598

599599
MCSection(StringRef Name, bool IsText, bool IsBss, MCSymbol *Begin);
600-
// Protected non-virtual dtor prevents destroy through a base class pointer.
601-
~MCSection() {}
602600

603601
public:
604602
MCSection(const MCSection &) = delete;
@@ -648,10 +646,6 @@ class LLVM_ABI MCSection {
648646
void dump(DenseMap<const MCFragment *, SmallVector<const MCSymbol *, 0>>
649647
*FragToSyms = nullptr) const;
650648

651-
virtual void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
652-
raw_ostream &OS,
653-
uint32_t Subsection) const {}
654-
655649
/// Check whether this section is "virtual", that is has no actual object
656650
/// file contents.
657651
bool isBssSection() const { return IsBss; }

llvm/include/llvm/MC/MCSectionCOFF.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class MCSectionCOFF final : public MCSection {
5151

5252
private:
5353
friend class MCContext;
54+
friend class MCAsmInfoCOFF;
5455
// The storage of Name is owned by MCContext's COFFUniquingMap.
5556
MCSectionCOFF(StringRef Name, unsigned Characteristics,
5657
MCSymbol *COMDATSymbol, int Selection, unsigned UniqueID,
@@ -67,7 +68,7 @@ class MCSectionCOFF final : public MCSection {
6768
public:
6869
/// Decides whether a '.section' directive should be printed before the
6970
/// section name
70-
bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
71+
bool shouldOmitSectionDirective(StringRef Name) const;
7172

7273
unsigned getCharacteristics() const { return Characteristics; }
7374
MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
@@ -78,10 +79,6 @@ class MCSectionCOFF final : public MCSection {
7879
bool isUnique() const { return UniqueID != NonUniqueID; }
7980
unsigned getUniqueID() const { return UniqueID; }
8081

81-
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
82-
raw_ostream &OS,
83-
uint32_t Subsection) const override;
84-
8582
unsigned getOrAssignWinCFISectionID(unsigned *NextID) const {
8683
if (WinCFISectionID == ~0U)
8784
WinCFISectionID = (*NextID)++;

llvm/include/llvm/MC/MCSectionELF.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class MCSectionELF final : public MCSection {
5252

5353
private:
5454
friend class MCContext;
55+
friend class MCAsmInfoELF;
5556

5657
// The storage of Name is owned by MCContext's ELFUniquingMap.
5758
MCSectionELF(StringRef Name, unsigned type, unsigned flags,
@@ -69,21 +70,13 @@ class MCSectionELF final : public MCSection {
6970
}
7071

7172
public:
72-
/// Decides whether a '.section' directive should be printed before the
73-
/// section name
74-
bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
75-
7673
unsigned getType() const { return Type; }
7774
unsigned getFlags() const { return Flags; }
7875
unsigned getEntrySize() const { return EntrySize; }
7976
void setFlags(unsigned F) { Flags = F; }
8077
const MCSymbolELF *getGroup() const { return Group.getPointer(); }
8178
bool isComdat() const { return Group.getInt(); }
8279

83-
void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
84-
raw_ostream &OS,
85-
uint32_t Subsection) const override;
86-
8780
bool isUnique() const { return UniqueID != NonUniqueID; }
8881
unsigned getUniqueID() const { return UniqueID; }
8982

0 commit comments

Comments
 (0)