Skip to content

Commit

Permalink
DebugInfo: Simplify section label caching/usage
Browse files Browse the repository at this point in the history
llvm-svn: 373273
  • Loading branch information
dwblaikie committed Sep 30, 2019
1 parent 63e8a0f commit 3845677
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
Expand Up @@ -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;
}

Expand Down
12 changes: 4 additions & 8 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

0 comments on commit 3845677

Please sign in to comment.