Skip to content

Commit eedc72b

Browse files
committed
MCSection: Replace DummyFragment with the Subsections[0] head fragment
The dummy fragment is primarily used by MCAsmStreamer::emitLabel to track the defined state. We can replace it with an arbitrary fragment. Remove MCDummyFragment introduced for #24860
1 parent dfaa662 commit eedc72b

File tree

6 files changed

+3
-25
lines changed

6 files changed

+3
-25
lines changed

llvm/include/llvm/MC/MCFragment.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class MCFragment {
5050
FT_CVInlineLines,
5151
FT_CVDefRange,
5252
FT_PseudoProbe,
53-
FT_Dummy
5453
};
5554

5655
private:
@@ -111,13 +110,6 @@ class MCFragment {
111110
void dump() const;
112111
};
113112

114-
class MCDummyFragment : public MCFragment {
115-
public:
116-
explicit MCDummyFragment() : MCFragment(FT_Dummy, false) {}
117-
118-
static bool classof(const MCFragment *F) { return F->getKind() == FT_Dummy; }
119-
};
120-
121113
/// Interface implemented by fragments that contain encoded instructions and/or
122114
/// data.
123115
///

llvm/include/llvm/MC/MCSection.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ class MCSection {
111111
/// offset between two locations may not be fully resolved.
112112
bool LinkerRelaxable : 1;
113113

114-
MCDummyFragment DummyFragment;
115-
116114
// Mapping from subsection number to fragment list. At layout time, the
117115
// subsection 0 list is replaced with concatenated fragments from all
118116
// subsections.
@@ -182,8 +180,7 @@ class MCSection {
182180
bool isLinkerRelaxable() const { return LinkerRelaxable; }
183181
void setLinkerRelaxable() { LinkerRelaxable = true; }
184182

185-
const MCDummyFragment &getDummyFragment() const { return DummyFragment; }
186-
MCDummyFragment &getDummyFragment() { return DummyFragment; }
183+
MCFragment &getDummyFragment() { return *Subsections[0].second.Head; }
187184

188185
FragList *curFragList() const { return CurFragList; }
189186
iterator begin() const { return iterator(CurFragList->Head); }

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,6 @@ uint64_t MCAssembler::computeFragmentSize(const MCFragment &F) const {
300300
return cast<MCCVDefRangeFragment>(F).getContents().size();
301301
case MCFragment::FT_PseudoProbe:
302302
return cast<MCPseudoProbeAddrFragment>(F).getContents().size();
303-
case MCFragment::FT_Dummy:
304-
llvm_unreachable("Should not have been added");
305303
}
306304

307305
llvm_unreachable("invalid fragment kind");
@@ -767,8 +765,6 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
767765
OS << PF.getContents();
768766
break;
769767
}
770-
case MCFragment::FT_Dummy:
771-
llvm_unreachable("Should not have been added");
772768
}
773769

774770
assert(OS.tell() - Start == FragmentSize &&
@@ -846,7 +842,7 @@ void MCAssembler::layout() {
846842

847843
// Chain together fragments from all subsections.
848844
if (Sec.Subsections.size() > 1) {
849-
MCDummyFragment Dummy;
845+
MCDataFragment Dummy;
850846
MCFragment *Tail = &Dummy;
851847
for (auto &[_, List] : Sec.Subsections) {
852848
assert(List.Head);

llvm/lib/MC/MCFragment.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ void MCFragment::destroy() {
7272
case FT_PseudoProbe:
7373
cast<MCPseudoProbeAddrFragment>(this)->~MCPseudoProbeAddrFragment();
7474
return;
75-
case FT_Dummy:
76-
cast<MCDummyFragment>(this)->~MCDummyFragment();
77-
return;
7875
}
7976
}
8077

@@ -119,7 +116,6 @@ LLVM_DUMP_METHOD void MCFragment::dump() const {
119116
case MCFragment::FT_PseudoProbe:
120117
OS << "MCPseudoProbe";
121118
break;
122-
case MCFragment::FT_Dummy: OS << "MCDummyFragment"; break;
123119
}
124120

125121
OS << "<MCFragment " << (const void *)this << " LayoutOrder:" << LayoutOrder
@@ -241,8 +237,6 @@ LLVM_DUMP_METHOD void MCFragment::dump() const {
241237
OS << " AddrDelta:" << OF->getAddrDelta();
242238
break;
243239
}
244-
case MCFragment::FT_Dummy:
245-
break;
246240
}
247241
OS << ">";
248242
}

llvm/lib/MC/MCSection.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ MCSection::MCSection(SectionVariant V, StringRef Name, bool IsText,
2424
: Begin(Begin), BundleGroupBeforeFirstInst(false), HasInstructions(false),
2525
HasLayout(false), IsRegistered(false), IsText(IsText),
2626
IsVirtual(IsVirtual), LinkerRelaxable(false), Name(Name), Variant(V) {
27-
DummyFragment.setParent(this);
2827
// The initial subsection number is 0. Create a fragment list.
2928
CurFragList = &Subsections.emplace_back(0u, FragList{}).second;
3029
}

llvm/lib/MC/MCSymbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
using namespace llvm;
2323

2424
// Only the address of this fragment is ever actually used.
25-
static MCDummyFragment SentinelFragment;
25+
static MCDataFragment SentinelFragment;
2626

2727
// Sentinel value for the absolute pseudo fragment.
2828
MCFragment *MCSymbol::AbsolutePseudoFragment = &SentinelFragment;

0 commit comments

Comments
 (0)