DebugInfo: Move unit begin/end labels into the unit

This removes another case of spooky action at a distance (building the
same label names in multiple places creating an implicit dependency
between those places) and helps pave the way for type units.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196617 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2013-12-06 22:33:05 +00:00
parent b5a244bd54
commit b0ec1be634
2 changed files with 29 additions and 22 deletions

View File

@ -2137,8 +2137,7 @@ void DwarfFile::emitUnits(DwarfDebug *DD, const MCSection *ASection,
Asm->OutStreamer.SwitchSection(USection);
// Emit the compile units header.
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol(USection->getLabelBeginName(), TheU->getUniqueID()));
Asm->OutStreamer.EmitLabel(TheU->getLabelBegin());
// Emit size of content not including length itself
Asm->OutStreamer.AddComment("Length of Unit");
@ -2147,8 +2146,7 @@ void DwarfFile::emitUnits(DwarfDebug *DD, const MCSection *ASection,
TheU->emitHeader(ASection, ASectionSym);
DD->emitDIE(Die);
Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol(USection->getLabelEndName(), TheU->getUniqueID()));
Asm->OutStreamer.EmitLabel(TheU->getLabelEnd());
}
}
@ -2414,7 +2412,6 @@ static dwarf::PubIndexEntryDescriptor computeIndexValue(Unit *CU,
/// emitDebugPubNames - Emit visible names into a debug pubnames section.
///
void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
const MCSection *ISec = Asm->getObjFileLowering().getDwarfInfoSection();
const MCSection *PSec =
GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubNamesSection()
: Asm->getObjFileLowering().getDwarfPubNamesSection();
@ -2444,13 +2441,10 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
Asm->EmitInt16(dwarf::DW_PUBNAMES_VERSION);
Asm->OutStreamer.AddComment("Offset of Compilation Unit Info");
Asm->EmitSectionOffset(Asm->GetTempSymbol(ISec->getLabelBeginName(), ID),
TheU->getSectionSym());
Asm->EmitSectionOffset(TheU->getLabelBegin(), TheU->getSectionSym());
Asm->OutStreamer.AddComment("Compilation Unit Length");
Asm->EmitLabelDifference(Asm->GetTempSymbol(ISec->getLabelEndName(), ID),
Asm->GetTempSymbol(ISec->getLabelBeginName(), ID),
4);
Asm->EmitLabelDifference(TheU->getLabelEnd(), TheU->getLabelBegin(), 4);
// Emit the pubnames for this compilation unit.
const StringMap<const DIE *> &Globals = getUnits()[ID]->getGlobalNames();
@ -2482,7 +2476,6 @@ void DwarfDebug::emitDebugPubNames(bool GnuStyle) {
}
void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
const MCSection *ISec = Asm->getObjFileLowering().getDwarfInfoSection();
const MCSection *PSec =
GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubTypesSection()
: Asm->getObjFileLowering().getDwarfPubTypesSection();
@ -2512,14 +2505,10 @@ void DwarfDebug::emitDebugPubTypes(bool GnuStyle) {
Asm->EmitInt16(dwarf::DW_PUBTYPES_VERSION);
Asm->OutStreamer.AddComment("Offset of Compilation Unit Info");
Asm->EmitSectionOffset(
Asm->GetTempSymbol(ISec->getLabelBeginName(), TheU->getUniqueID()),
TheU->getSectionSym());
Asm->EmitSectionOffset(TheU->getLabelBegin(), TheU->getSectionSym());
Asm->OutStreamer.AddComment("Compilation Unit Length");
Asm->EmitLabelDifference(
Asm->GetTempSymbol(ISec->getLabelEndName(), TheU->getUniqueID()),
Asm->GetTempSymbol(ISec->getLabelBeginName(), TheU->getUniqueID()), 4);
Asm->EmitLabelDifference(TheU->getLabelEnd(), TheU->getLabelBegin(), 4);
// Emit the pubtypes.
const StringMap<const DIE *> &Globals = getUnits()[ID]->getGlobalTypes();
@ -2825,7 +2814,6 @@ void DwarfDebug::emitDebugARanges() {
}
}
const MCSection *ISec = Asm->getObjFileLowering().getDwarfInfoSection();
unsigned PtrSize = Asm->getDataLayout().getPointerSize();
// Build a list of CUs used.
@ -2866,9 +2854,7 @@ void DwarfDebug::emitDebugARanges() {
Asm->OutStreamer.AddComment("DWARF Arange version number");
Asm->EmitInt16(dwarf::DW_ARANGES_VERSION);
Asm->OutStreamer.AddComment("Offset Into Debug Info Section");
Asm->EmitSectionOffset(
Asm->GetTempSymbol(ISec->getLabelBeginName(), CU->getUniqueID()),
CU->getSectionSym());
Asm->EmitSectionOffset(CU->getLabelBegin(), CU->getSectionSym());
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(PtrSize);
Asm->OutStreamer.AddComment("Segment Size (in bytes)");

View File

@ -22,6 +22,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/DebugInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSection.h"
namespace llvm {
@ -133,6 +134,12 @@ protected:
/// A label at the start of the non-dwo section related to this unit.
MCSymbol *SectionSym;
/// The start of the unit within its section.
MCSymbol *LabelBegin;
/// The end of the unit within its section.
MCSymbol *LabelEnd;
Unit(unsigned UID, DIE *D, DICompileUnit CU, AsmPrinter *A, DwarfDebug *DW,
DwarfFile *DWU);
@ -146,17 +153,31 @@ public:
assert(!this->Section);
this->Section = Section;
this->SectionSym = SectionSym;
this->LabelBegin =
Asm->GetTempSymbol(Section->getLabelBeginName(), getUniqueID());
this->LabelEnd =
Asm->GetTempSymbol(Section->getLabelEndName(), getUniqueID());
}
const MCSection *getSection() const {
assert(Section);
return Section;
}
MCSymbol *getSectionSym() {
MCSymbol *getSectionSym() const {
assert(Section);
return SectionSym;
}
MCSymbol *getLabelBegin() const {
assert(Section);
return LabelBegin;
}
MCSymbol *getLabelEnd() const {
assert(Section);
return LabelEnd;
}
// Accessors.
unsigned getUniqueID() const { return UniqueID; }
virtual uint16_t getLanguage() const = 0;