Commit 58b10df5 authored by David Blaikie's avatar David Blaikie
Browse files

DebugInfo: Move SectionLabel tracking into CU's addRange

This makes the SectionLabel handling more resilient - specifically for
future PROPELLER work which will have more CU ranges (rather than just
one per function).

Ultimately it might be nice to make this more general/resilient to
arbitrary labels (rather than relying on the labels being created for CU
ranges & then being reused by ranges, loclists, and possibly other
addresses). It's possible that other (non-rnglist/loclist) uses of
addresses will need the addresses to be in SectionLabels earlier (eg:
move the CU.addRange to be done on function begin, rather than function
end, so during function emission they are already populated for other
use).
parent 46ed9331
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -328,6 +328,8 @@ DIE *DwarfCompileUnit::getOrCreateCommonBlock(
}

void DwarfCompileUnit::addRange(RangeSpan Range) {
  DD->insertSectionLabel(Range.Begin);

  bool SameAsPrevCU = this == DD->getPrevCU();
  DD->setPrevCU(this);
  // If we have no current ranges just add the range and return, otherwise,
+6 −5
Original line number Diff line number Diff line
@@ -1833,9 +1833,6 @@ 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
@@ -2532,8 +2529,9 @@ void DwarfDebug::emitDebugLocDWO() {
      // offset_pair, so the implementations can't really share much since they
      // need to use different representations)
      // * as of October 2018, at least
      // Ideally/in v5, this could use SectionLabels to reuse existing addresses
      // in the address pool to minimize object size/relocations.
      //
      // In v5 (see emitLocList), this uses SectionLabels to reuse existing
      // addresses in the address pool to minimize object size/relocations.
      Asm->emitInt8(dwarf::DW_LLE_startx_length);
      unsigned idx = AddrPool.getIndex(Entry.Begin);
      Asm->EmitULEB128(idx);
@@ -3077,3 +3075,6 @@ uint16_t DwarfDebug::getDwarfVersion() const {
const MCSymbol *DwarfDebug::getSectionLabel(const MCSection *S) {
  return SectionLabels.find(S)->second;
}
void DwarfDebug::insertSectionLabel(const MCSymbol *S) {
  SectionLabels.insert(std::make_pair(&S->getSection(), S));
}
+1 −0
Original line number Diff line number Diff line
@@ -768,6 +768,7 @@ public:

  void addSectionLabel(const MCSymbol *Sym);
  const MCSymbol *getSectionLabel(const MCSection *S);
  void insertSectionLabel(const MCSymbol *S);

  static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
                                const DbgValueLoc &Value,