DwarfDebug: Avoid unnecessary abbreviation lookup when emitting DIEs

DIEs already contain references directly to their DIEAbbrev, use that
instead of looking it up based on index.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196446 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2013-12-05 01:01:41 +00:00
parent acf6571d80
commit 7afb463a65
2 changed files with 16 additions and 18 deletions

View File

@@ -1926,17 +1926,16 @@ unsigned DwarfUnits::computeSizeAndOffset(DIE *Die, unsigned Offset) {
assignAbbrevNumber(Die->getAbbrev()); assignAbbrevNumber(Die->getAbbrev());
// Get the abbreviation for this DIE. // Get the abbreviation for this DIE.
unsigned AbbrevNumber = Die->getAbbrevNumber(); const DIEAbbrev &Abbrev = Die->getAbbrev();
const DIEAbbrev *Abbrev = Abbreviations[AbbrevNumber - 1];
// Set DIE offset // Set DIE offset
Die->setOffset(Offset); Die->setOffset(Offset);
// Start the size with the size of abbreviation code. // Start the size with the size of abbreviation code.
Offset += MCAsmInfo::getULEB128Size(AbbrevNumber); Offset += MCAsmInfo::getULEB128Size(Die->getAbbrevNumber());
const SmallVectorImpl<DIEValue *> &Values = Die->getValues(); const SmallVectorImpl<DIEValue *> &Values = Die->getValues();
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev->getData(); const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
// Size the DIE attribute values. // Size the DIE attribute values.
for (unsigned i = 0, N = Values.size(); i < N; ++i) for (unsigned i = 0, N = Values.size(); i < N; ++i)
@@ -1945,7 +1944,7 @@ unsigned DwarfUnits::computeSizeAndOffset(DIE *Die, unsigned Offset) {
// Size the DIE children if any. // Size the DIE children if any.
if (!Children.empty()) { if (!Children.empty()) {
assert(Abbrev->getChildrenFlag() == dwarf::DW_CHILDREN_yes && assert(Abbrev.getChildrenFlag() == dwarf::DW_CHILDREN_yes &&
"Children flag not set"); "Children flag not set");
for (unsigned j = 0, M = Children.size(); j < M; ++j) for (unsigned j = 0, M = Children.size(); j < M; ++j)
@@ -2030,21 +2029,20 @@ void DwarfDebug::emitSectionLabels() {
} }
// Recursively emits a debug information entry. // Recursively emits a debug information entry.
void DwarfDebug::emitDIE(DIE *Die, ArrayRef<DIEAbbrev *> Abbrevs) { void DwarfDebug::emitDIE(DIE *Die) {
// Get the abbreviation for this DIE. // Get the abbreviation for this DIE.
unsigned AbbrevNumber = Die->getAbbrevNumber(); const DIEAbbrev &Abbrev = Die->getAbbrev();
const DIEAbbrev *Abbrev = Abbrevs[AbbrevNumber - 1];
// Emit the code (index) for the abbreviation. // Emit the code (index) for the abbreviation.
if (Asm->isVerbose()) if (Asm->isVerbose())
Asm->OutStreamer.AddComment("Abbrev [" + Twine(AbbrevNumber) + "] 0x" + Asm->OutStreamer.AddComment("Abbrev [" + Twine(Abbrev.getNumber()) +
Twine::utohexstr(Die->getOffset()) + ":0x" + "] 0x" + Twine::utohexstr(Die->getOffset()) +
Twine::utohexstr(Die->getSize()) + " " + ":0x" + Twine::utohexstr(Die->getSize()) + " " +
dwarf::TagString(Abbrev->getTag())); dwarf::TagString(Abbrev.getTag()));
Asm->EmitULEB128(AbbrevNumber); Asm->EmitULEB128(Abbrev.getNumber());
const SmallVectorImpl<DIEValue *> &Values = Die->getValues(); const SmallVectorImpl<DIEValue *> &Values = Die->getValues();
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev->getData(); const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
// Emit the DIE attribute values. // Emit the DIE attribute values.
for (unsigned i = 0, N = Values.size(); i < N; ++i) { for (unsigned i = 0, N = Values.size(); i < N; ++i) {
@@ -2115,11 +2113,11 @@ void DwarfDebug::emitDIE(DIE *Die, ArrayRef<DIEAbbrev *> Abbrevs) {
} }
// Emit the DIE children if any. // Emit the DIE children if any.
if (Abbrev->getChildrenFlag() == dwarf::DW_CHILDREN_yes) { if (Abbrev.getChildrenFlag() == dwarf::DW_CHILDREN_yes) {
const std::vector<DIE *> &Children = Die->getChildren(); const std::vector<DIE *> &Children = Die->getChildren();
for (unsigned j = 0, M = Children.size(); j < M; ++j) for (unsigned j = 0, M = Children.size(); j < M; ++j)
emitDIE(Children[j], Abbrevs); emitDIE(Children[j]);
Asm->OutStreamer.AddComment("End Of Children Mark"); Asm->OutStreamer.AddComment("End Of Children Mark");
Asm->EmitInt8(0); Asm->EmitInt8(0);
@@ -2147,7 +2145,7 @@ void DwarfUnits::emitUnits(DwarfDebug *DD, const MCSection *USection,
TheU->emitHeader(ASection, ASectionSym); TheU->emitHeader(ASection, ASectionSym);
DD->emitDIE(Die, Abbreviations); DD->emitDIE(Die);
Asm->OutStreamer.EmitLabel( Asm->OutStreamer.EmitLabel(
Asm->GetTempSymbol(USection->getLabelEndName(), TheU->getUniqueID())); Asm->GetTempSymbol(USection->getLabelEndName(), TheU->getUniqueID()));
} }

View File

@@ -734,7 +734,7 @@ public:
unsigned CUID); unsigned CUID);
/// \brief Recursively Emits a debug information entry. /// \brief Recursively Emits a debug information entry.
void emitDIE(DIE *Die, ArrayRef<DIEAbbrev *> Abbrevs); void emitDIE(DIE *Die);
// Experimental DWARF5 features. // Experimental DWARF5 features.