From 6576623cbed448a5ab8179d0c845980915a47c1e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 30 Sep 2019 23:19:10 +0000 Subject: [PATCH] DebugInfo: Simplify section label caching/usage git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373273 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 1 - lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 12 ++++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index edc8cefa3e2..c1c5c4f010c 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -329,7 +329,6 @@ void DwarfCompileUnit::addRange(RangeSpan Range) { (&CURanges.back().getEnd()->getSection() != &Range.getEnd()->getSection())) { CURanges.push_back(Range); - DD->addSectionLabel(Range.getStart()); return; } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 273d2050e4a..ea39668d36d 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1757,6 +1757,9 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) { if (SP->getUnit()->getEmissionKind() == DICompileUnit::NoDebug) return; + SectionLabels.insert(std::make_pair(&Asm->getFunctionBegin()->getSection(), + Asm->getFunctionBegin())); + DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(SP->getUnit()); // Set DwarfDwarfCompileUnitID in MCContext to the Compile Unit this function @@ -2582,11 +2585,8 @@ static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm, if (!Base && (P.second.size() > 1 || DwarfVersion < 5) && (CU.getCUNode()->getRangesBaseAddress() || DwarfVersion >= 5)) { BaseIsSet = true; - // FIXME/use care: This may not be a useful base address if it's not - // the lowest address/range in this object. - Base = P.second.front()->getStart(); + Base = DD.getSectionLabel(&P.second.front()->getStart()->getSection()); if (DwarfVersion >= 5) { - Base = DD.getSectionLabel(&Base->getSection()); Asm->OutStreamer->AddComment("DW_RLE_base_addressx"); Asm->OutStreamer->EmitIntValue(dwarf::DW_RLE_base_addressx, 1); Asm->OutStreamer->AddComment(" base address index"); @@ -3029,10 +3029,6 @@ uint16_t DwarfDebug::getDwarfVersion() const { return Asm->OutStreamer->getContext().getDwarfVersion(); } -void DwarfDebug::addSectionLabel(const MCSymbol *Sym) { - SectionLabels.insert(std::make_pair(&Sym->getSection(), Sym)); -} - const MCSymbol *DwarfDebug::getSectionLabel(const MCSection *S) { return SectionLabels.find(S)->second; } -- 2.50.1