[llvm] r347134 - llvm-symbolizer: Avoid calling getFromOffset when the index entry is already available
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 16 21:57:59 PST 2018
Author: dblaikie
Date: Fri Nov 16 21:57:58 2018
New Revision: 347134
URL: http://llvm.org/viewvc/llvm-project?rev=347134&view=rev
Log:
llvm-symbolizer: Avoid calling getFromOffset when the index entry is already available
Especially for symbolizer it can be efficient to have to search through
the entire index when it isn't needed - llvm-symbolizer looks up only a
few CUs & already has an index available in getUnitForEntry, once it's
passed down to DWARFUnitHeader::extract then there's no need for it to
call getFromOffset.
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=347134&r1=347133&r2=347134&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Fri Nov 16 21:57:58 2018
@@ -72,7 +72,8 @@ public:
/// Parse a unit header from \p debug_info starting at \p offset_ptr.
bool extract(DWARFContext &Context, const DWARFDataExtractor &debug_info,
uint32_t *offset_ptr, DWARFSectionKind Kind = DW_SECT_INFO,
- const DWARFUnitIndex *Index = nullptr);
+ const DWARFUnitIndex *Index = nullptr,
+ const DWARFUnitIndex::Entry *Entry = nullptr);
uint32_t getOffset() const { return Offset; }
const dwarf::FormParams &getFormParams() const { return FormParams; }
uint16_t getVersion() const { return FormParams.Version; }
@@ -108,7 +109,8 @@ const DWARFUnitIndex &getDWARFUnitIndex(
/// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo.
class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
std::function<std::unique_ptr<DWARFUnit>(uint32_t, DWARFSectionKind,
- const DWARFSection *)>
+ const DWARFSection *,
+ const DWARFUnitIndex::Entry *)>
Parser;
int NumInfoUnits = -1;
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=347134&r1=347133&r2=347134&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Fri Nov 16 21:57:58 2018
@@ -66,9 +66,11 @@ void DWARFUnitVector::addUnitsImpl(
DWARFDataExtractor Data(Obj, Section, LE, 0);
// Lazy initialization of Parser, now that we have all section info.
if (!Parser) {
- Parser = [=, &Context, &Obj, &Section, &SOS, &LS](
- uint32_t Offset, DWARFSectionKind SectionKind,
- const DWARFSection *CurSection) -> std::unique_ptr<DWARFUnit> {
+ Parser = [=, &Context, &Obj, &Section, &SOS,
+ &LS](uint32_t Offset, DWARFSectionKind SectionKind,
+ const DWARFSection *CurSection,
+ const DWARFUnitIndex::Entry *IndexEntry)
+ -> std::unique_ptr<DWARFUnit> {
const DWARFSection &InfoSection = CurSection ? *CurSection : Section;
DWARFDataExtractor Data(Obj, InfoSection, LE, 0);
if (!Data.isValidOffset(Offset))
@@ -77,7 +79,8 @@ void DWARFUnitVector::addUnitsImpl(
if (IsDWO)
Index = &getDWARFUnitIndex(Context, SectionKind);
DWARFUnitHeader Header;
- if (!Header.extract(Context, Data, &Offset, SectionKind, Index))
+ if (!Header.extract(Context, Data, &Offset, SectionKind, Index,
+ IndexEntry))
return nullptr;
std::unique_ptr<DWARFUnit> U;
if (Header.isTypeUnit())
@@ -106,7 +109,7 @@ void DWARFUnitVector::addUnitsImpl(
++I;
continue;
}
- auto U = Parser(Offset, SectionKind, &Section);
+ auto U = Parser(Offset, SectionKind, &Section, nullptr);
// If parsing failed, we're done with this section.
if (!U)
break;
@@ -156,7 +159,7 @@ DWARFUnitVector::getUnitForIndexEntry(co
if (!Parser)
return nullptr;
- auto U = Parser(Offset, DW_SECT_INFO, nullptr);
+ auto U = Parser(Offset, DW_SECT_INFO, nullptr, &E);
if (!U)
U = nullptr;
@@ -233,9 +236,12 @@ bool DWARFUnitHeader::extract(DWARFConte
const DWARFDataExtractor &debug_info,
uint32_t *offset_ptr,
DWARFSectionKind SectionKind,
- const DWARFUnitIndex *Index) {
+ const DWARFUnitIndex *Index,
+ const DWARFUnitIndex::Entry *Entry) {
Offset = *offset_ptr;
- IndexEntry = Index ? Index->getFromOffset(*offset_ptr) : nullptr;
+ IndexEntry = Entry;
+ if (!IndexEntry && Index)
+ IndexEntry = Index->getFromOffset(*offset_ptr);
Length = debug_info.getU32(offset_ptr);
// FIXME: Support DWARF64.
unsigned SizeOfLength = 4;
More information about the llvm-commits
mailing list