From f6fc503b6791bd7d38ba62c249091eabed297471 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 29 Jun 2024 17:53:13 -0700 Subject: [PATCH] [MC] Remove MCStreamer::SymbolOrdering 21101b32318647f600584d966c697d8773f59629 (2013) added SymbolOrdering, which essentially became useless when e3a20f57d927e422874a8e7730bb7590515b586d (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. --- llvm/include/llvm/MC/MCStreamer.h | 10 ---------- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 14 -------------- llvm/lib/MC/MCStreamer.cpp | 5 ----- 3 files changed, 29 deletions(-) diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h index baa9c335920eb7..fa8e5c6fe81057 100644 --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -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 SymbolOrdering; - /// This is stack of current and previous section values saved by /// pushSection. SmallVector, 4> SectionStack; @@ -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( diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index dd7d9e5deac2e2..2addf938c8b638 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -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))); diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 67cb14d7291573..470c673a897d8b 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -102,7 +102,6 @@ void MCStreamer::reset() { DwarfFrameInfos.clear(); CurrentWinFrameInfo = nullptr; WinFrameInfos.clear(); - SymbolOrdering.clear(); SectionStack.clear(); SectionStack.push_back(std::pair()); CurFrag = nullptr; @@ -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) {