From 209c4e345a7f9d68627b969f2cf31da97a5999eb Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sat, 31 Aug 2019 01:05:46 +0000 Subject: [PATCH] llvm-dwarfdump: Cache CU low_pc when computing statistics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@370559 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-dwarfdump/Statistics.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/llvm-dwarfdump/Statistics.cpp b/tools/llvm-dwarfdump/Statistics.cpp index c76c77edb90..9b8b0682e73 100644 --- a/tools/llvm-dwarfdump/Statistics.cpp +++ b/tools/llvm-dwarfdump/Statistics.cpp @@ -85,7 +85,7 @@ static uint64_t getLowPC(DWARFDie Die) { } /// Collect debug info quality metrics for one DIE. -static void collectStatsForDie(DWARFDie Die, std::string FnPrefix, +static void collectStatsForDie(DWARFDie Die, uint64_t UnitLowPC, std::string FnPrefix, std::string VarPrefix, uint64_t ScopeLowPC, uint64_t BytesInScope, uint32_t InlineDepth, StringMap &FnStatMap, @@ -147,7 +147,7 @@ static void collectStatsForDie(DWARFDie Die, std::string FnPrefix, BytesCovered += Entry.End - Entry.Begin; if (List->Entries.size()) { uint64_t FirstDef = List->Entries[0].Begin; - uint64_t UnitOfs = getLowPC(Die.getDwarfUnit()->getUnitDIE()); + uint64_t UnitOfs = UnitLowPC; // Ranges sometimes start before the lexical scope. if (UnitOfs + FirstDef >= ScopeLowPC) OffsetToFirstDefinition = UnitOfs + FirstDef - ScopeLowPC; @@ -210,7 +210,7 @@ static void collectStatsForDie(DWARFDie Die, std::string FnPrefix, } /// Recursively collect debug info quality metrics. -static void collectStatsRecursive(DWARFDie Die, std::string FnPrefix, +static void collectStatsRecursive(DWARFDie Die, uint64_t UnitLowPC, std::string FnPrefix, std::string VarPrefix, uint64_t ScopeLowPC, uint64_t BytesInScope, uint32_t InlineDepth, StringMap &FnStatMap, @@ -282,7 +282,7 @@ static void collectStatsRecursive(DWARFDie Die, std::string FnPrefix, } } else { // Not a scope, visit the Die itself. It could be a variable. - collectStatsForDie(Die, FnPrefix, VarPrefix, ScopeLowPC, BytesInScope, + collectStatsForDie(Die, UnitLowPC, FnPrefix, VarPrefix, ScopeLowPC, BytesInScope, InlineDepth, FnStatMap, GlobalStats); } @@ -300,7 +300,7 @@ static void collectStatsRecursive(DWARFDie Die, std::string FnPrefix, if (Child.getTag() == dwarf::DW_TAG_lexical_block) ChildVarPrefix += toHex(LexicalBlockIndex++) + '.'; - collectStatsRecursive(Child, FnPrefix, ChildVarPrefix, ScopeLowPC, + collectStatsRecursive(Child, UnitLowPC, FnPrefix, ChildVarPrefix, ScopeLowPC, BytesInScope, InlineDepth, FnStatMap, GlobalStats); Child = Child.getSibling(); } @@ -334,7 +334,7 @@ bool collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx, StringMap Statistics; for (const auto &CU : static_cast(&DICtx)->compile_units()) if (DWARFDie CUDie = CU->getNonSkeletonUnitDIE(false)) - collectStatsRecursive(CUDie, "/", "g", 0, 0, 0, Statistics, GlobalStats); + collectStatsRecursive(CUDie, getLowPC(CUDie), "/", "g", 0, 0, 0, Statistics, GlobalStats); /// The version number should be increased every time the algorithm is changed /// (including bug fixes). New metrics may be added without increasing the -- 2.40.0