llvm.org GIT mirror llvm / 209c4e3
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 David Blaikie a month ago
1 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
8484 }
8585
8686 /// Collect debug info quality metrics for one DIE.
87 static void collectStatsForDie(DWARFDie Die, std::string FnPrefix,
87 static void collectStatsForDie(DWARFDie Die, uint64_t UnitLowPC, std::string FnPrefix,
8888 std::string VarPrefix, uint64_t ScopeLowPC,
8989 uint64_t BytesInScope, uint32_t InlineDepth,
9090 StringMap &FnStatMap,
146146 BytesCovered += Entry.End - Entry.Begin;
147147 if (List->Entries.size()) {
148148 uint64_t FirstDef = List->Entries[0].Begin;
149 uint64_t UnitOfs = getLowPC(Die.getDwarfUnit()->getUnitDIE());
149 uint64_t UnitOfs = UnitLowPC;
150150 // Ranges sometimes start before the lexical scope.
151151 if (UnitOfs + FirstDef >= ScopeLowPC)
152152 OffsetToFirstDefinition = UnitOfs + FirstDef - ScopeLowPC;
209209 }
210210
211211 /// Recursively collect debug info quality metrics.
212 static void collectStatsRecursive(DWARFDie Die, std::string FnPrefix,
212 static void collectStatsRecursive(DWARFDie Die, uint64_t UnitLowPC, std::string FnPrefix,
213213 std::string VarPrefix, uint64_t ScopeLowPC,
214214 uint64_t BytesInScope, uint32_t InlineDepth,
215215 StringMap &FnStatMap,
281281 }
282282 } else {
283283 // Not a scope, visit the Die itself. It could be a variable.
284 collectStatsForDie(Die, FnPrefix, VarPrefix, ScopeLowPC, BytesInScope,
284 collectStatsForDie(Die, UnitLowPC, FnPrefix, VarPrefix, ScopeLowPC, BytesInScope,
285285 InlineDepth, FnStatMap, GlobalStats);
286286 }
287287
299299 if (Child.getTag() == dwarf::DW_TAG_lexical_block)
300300 ChildVarPrefix += toHex(LexicalBlockIndex++) + '.';
301301
302 collectStatsRecursive(Child, FnPrefix, ChildVarPrefix, ScopeLowPC,
302 collectStatsRecursive(Child, UnitLowPC, FnPrefix, ChildVarPrefix, ScopeLowPC,
303303 BytesInScope, InlineDepth, FnStatMap, GlobalStats);
304304 Child = Child.getSibling();
305305 }
333333 StringMap Statistics;
334334 for (const auto &CU : static_cast(&DICtx)->compile_units())
335335 if (DWARFDie CUDie = CU->getNonSkeletonUnitDIE(false))
336 collectStatsRecursive(CUDie, "/", "g", 0, 0, 0, Statistics, GlobalStats);
336 collectStatsRecursive(CUDie, getLowPC(CUDie), "/", "g", 0, 0, 0, Statistics, GlobalStats);
337337
338338 /// The version number should be increased every time the algorithm is changed
339339 /// (including bug fixes). New metrics may be added without increasing the