diff options
| author | David Blaikie <dblaikie@gmail.com> | 2017-09-19 15:13:55 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2017-09-19 15:13:55 +0000 |
| commit | 485e01be26b27107b65fecc2464aec703ceaf3b7 (patch) | |
| tree | a93a85c8227b4689a3c0bcb85fa0e3c0702bfd60 /llvm/lib/DebugInfo/DWARF | |
| parent | 4a34338204aac2986f5d76ff7aa9e33d13abedc5 (diff) | |
| download | bcm5719-llvm-485e01be26b27107b65fecc2464aec703ceaf3b7.tar.gz bcm5719-llvm-485e01be26b27107b65fecc2464aec703ceaf3b7.zip | |
dwarfdump: Delay parsing abbreviations until they're needed
This speeds up dumping specific DIEs by not parsing abbreviations for
units that are not used.
(this is also handy to have in eventually to speed up llvm-symbolizer
for .dwp files, where parsing most of the DWP file can be avoided by
using the index)
llvm-svn: 313635
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp | 32 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 11 |
2 files changed, 33 insertions, 10 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp index 76dd2e4c21b..4830c36a8ee 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp @@ -68,9 +68,7 @@ DWARFAbbreviationDeclarationSet::getAbbreviationDeclaration( return &Decls[AbbrCode - FirstAbbrCode]; } -DWARFDebugAbbrev::DWARFDebugAbbrev() { - clear(); -} +DWARFDebugAbbrev::DWARFDebugAbbrev() { clear(); } void DWARFDebugAbbrev::clear() { AbbrDeclSets.clear(); @@ -79,18 +77,29 @@ void DWARFDebugAbbrev::clear() { void DWARFDebugAbbrev::extract(DataExtractor Data) { clear(); + this->Data = Data; +} +void DWARFDebugAbbrev::parse() const { + if (!Data) + return; uint32_t Offset = 0; DWARFAbbreviationDeclarationSet AbbrDecls; - while (Data.isValidOffset(Offset)) { + auto I = AbbrDeclSets.begin(); + while (Data->isValidOffset(Offset)) { + while (I != AbbrDeclSets.end() && I->first < Offset) + ++I; uint32_t CUAbbrOffset = Offset; - if (!AbbrDecls.extract(Data, &Offset)) + if (!AbbrDecls.extract(*Data, &Offset)) break; - AbbrDeclSets[CUAbbrOffset] = std::move(AbbrDecls); + AbbrDeclSets.insert(I, std::make_pair(CUAbbrOffset, std::move(AbbrDecls))); } + Data = None; } void DWARFDebugAbbrev::dump(raw_ostream &OS) const { + parse(); + if (AbbrDeclSets.empty()) { OS << "< EMPTY >\n"; return; @@ -115,5 +124,16 @@ DWARFDebugAbbrev::getAbbreviationDeclarationSet(uint64_t CUAbbrOffset) const { return &(Pos->second); } + if (Data && CUAbbrOffset < Data->getData().size()) { + uint32_t Offset = CUAbbrOffset; + DWARFAbbreviationDeclarationSet AbbrDecls; + if (!AbbrDecls.extract(*Data, &Offset)) + return nullptr; + PrevAbbrOffsetPos = + AbbrDeclSets.insert(std::make_pair(CUAbbrOffset, std::move(AbbrDecls))) + .first; + return &PrevAbbrOffsetPos->second; + } + return nullptr; } diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 813960ca95d..4467b4ac309 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -94,7 +94,6 @@ bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) { // FIXME: Support DWARF64. FormParams.Format = DWARF32; FormParams.Version = debug_info.getU16(offset_ptr); - uint64_t AbbrOffset; if (FormParams.Version >= 5) { UnitType = debug_info.getU8(offset_ptr); FormParams.AddrSize = debug_info.getU8(offset_ptr); @@ -124,9 +123,7 @@ bool DWARFUnit::extractImpl(DataExtractor debug_info, uint32_t *offset_ptr) { // Keep track of the highest DWARF version we encounter across all units. Context.setMaxVersionIfGreater(getVersion()); - - Abbrevs = Abbrev->getAbbreviationDeclarationSet(AbbrOffset); - return Abbrevs != nullptr; + return true; } bool DWARFUnit::extract(DataExtractor debug_info, uint32_t *offset_ptr) { @@ -452,3 +449,9 @@ DWARFDie DWARFUnit::getSibling(const DWARFDebugInfoEntry *Die) { } return DWARFDie(); } + +const DWARFAbbreviationDeclarationSet *DWARFUnit::getAbbreviations() const { + if (!Abbrevs) + Abbrevs = Abbrev->getAbbreviationDeclarationSet(AbbrOffset); + return Abbrevs; +} |

