Skip to content

Commit

Permalink
[MC] Remove MCStreamer::SymbolOrdering
Browse files Browse the repository at this point in the history
21101b3 (2013) added SymbolOrdering,
which essentially became useless when
e3a20f5 (2015) removed `AssignSection`
from `EmitLabel`. `assignFragment` is still used in very few places like
emitTBSSSymbol, which do not make a difference if we remove
SymbolOrdering.
  • Loading branch information
MaskRay committed Jun 30, 2024
1 parent 66518ad commit f6fc503
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 29 deletions.
10 changes: 0 additions & 10 deletions llvm/include/llvm/MC/MCStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ class MCStreamer {
WinEH::FrameInfo *CurrentWinFrameInfo;
size_t CurrentProcWinFrameInfoStartIndex;

/// Tracks an index to represent the order a symbol was emitted in.
/// Zero means we did not emit that symbol.
DenseMap<const MCSymbol *, unsigned> SymbolOrdering;

/// This is stack of current and previous section values saved by
/// pushSection.
SmallVector<std::pair<MCSectionSubPair, MCSectionSubPair>, 4> SectionStack;
Expand Down Expand Up @@ -416,12 +412,6 @@ class MCStreamer {
return CurFrag;
}

/// Returns an index to represent the order a symbol was emitted in.
/// (zero if we did not emit that symbol)
unsigned getSymbolOrder(const MCSymbol *Sym) const {
return SymbolOrdering.lookup(Sym);
}

/// Save the current and previous section on the section stack.
void pushSection() {
SectionStack.push_back(
Expand Down
14 changes: 0 additions & 14 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3028,20 +3028,6 @@ void DwarfDebug::emitDebugARanges() {
continue;
}

// Sort the symbols by offset within the section.
llvm::stable_sort(List, [&](const SymbolCU &A, const SymbolCU &B) {
unsigned IA = A.Sym ? Asm->OutStreamer->getSymbolOrder(A.Sym) : 0;
unsigned IB = B.Sym ? Asm->OutStreamer->getSymbolOrder(B.Sym) : 0;

// Symbols with no order assigned should be placed at the end.
// (e.g. section end labels)
if (IA == 0)
return false;
if (IB == 0)
return true;
return IA < IB;
});

// Insert a final terminator.
List.push_back(SymbolCU(nullptr, Asm->OutStreamer->endSection(Section)));

Expand Down
5 changes: 0 additions & 5 deletions llvm/lib/MC/MCStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ void MCStreamer::reset() {
DwarfFrameInfos.clear();
CurrentWinFrameInfo = nullptr;
WinFrameInfos.clear();
SymbolOrdering.clear();
SectionStack.clear();
SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>());
CurFrag = nullptr;
Expand Down Expand Up @@ -415,10 +414,6 @@ void MCStreamer::initSections(bool NoExecStack, const MCSubtargetInfo &STI) {
void MCStreamer::assignFragment(MCSymbol *Symbol, MCFragment *Fragment) {
assert(Fragment);
Symbol->setFragment(Fragment);

// As we emit symbols into a section, track the order so that they can
// be sorted upon later. Zero is reserved to mean 'unemitted'.
SymbolOrdering[Symbol] = 1 + SymbolOrdering.size();
}

void MCStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
Expand Down

0 comments on commit f6fc503

Please sign in to comment.