Index: test/tools/llvm-dwarfdump/X86/statistics.ll =================================================================== --- test/tools/llvm-dwarfdump/X86/statistics.ll +++ test/tools/llvm-dwarfdump/X86/statistics.ll @@ -1,6 +1,6 @@ ; RUN: llc -O0 %s -o - -filetype=obj \ ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s -; CHECK: "version":1 +; CHECK: "version":2 ; int GlobalConst = 42; ; int Global; Index: test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll =================================================================== --- test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll +++ test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll @@ -4,9 +4,9 @@ ; Test that abstract origins in multiple CUs are uniqued. ; CHECK: "source functions":4, -; CHECK-SAME: "inlined functions":5, +; CHECK-SAME: "inlined functions":2, ; CHECK-SAME: "unique source variables":4 -; CHECK-SAME: "source variables":6 +; CHECK-SAME: "source variables":8 ; CHECK-SAME: "variables with location":6 ;header.h: Index: test/tools/llvm-dwarfdump/X86/stats-inlining-single-cu.ll =================================================================== --- test/tools/llvm-dwarfdump/X86/stats-inlining-single-cu.ll +++ test/tools/llvm-dwarfdump/X86/stats-inlining-single-cu.ll @@ -5,9 +5,9 @@ ; The results for both tests should be identical. ; CHECK: "source functions":4, -; CHECK-SAME: "inlined functions":5, +; CHECK-SAME: "inlined functions":2, ; CHECK-SAME: "unique source variables":4 -; CHECK-SAME: "source variables":6 +; CHECK-SAME: "source variables":8 ; CHECK-SAME: "variables with location":6 ;header.h: Index: tools/llvm-dwarfdump/Statistics.cpp =================================================================== --- tools/llvm-dwarfdump/Statistics.cpp +++ tools/llvm-dwarfdump/Statistics.cpp @@ -136,8 +136,10 @@ GlobalStats.ScopeBytesFromFirstDefinition += BytesInScope; assert(GlobalStats.ScopeBytesCovered <= GlobalStats.ScopeBytesFromFirstDefinition); - } else { + } else if (Die.getTag() == dwarf::DW_TAG_member) { FnStats.ConstantMembers++; + } else { + FnStats.TotalVarWithLoc += (unsigned)HasLoc; } } @@ -175,7 +177,8 @@ return; // We've seen an (inlined) instance of this function. auto &FnStats = FnStatMap[Name]; - FnStats.NumFnInlined++; + if (IsInlinedFunction) + FnStats.NumFnInlined++; FnStats.IsFunction = true; } @@ -258,7 +261,7 @@ /// The version number should be increased every time the algorithm is changed /// (including bug fixes). New metrics may be added without increasing the /// version. - unsigned Version = 1; + unsigned Version = 2; unsigned VarTotal = 0; unsigned VarUnique = 0; unsigned VarWithLoc = 0; @@ -266,10 +269,10 @@ unsigned NumInlinedFunctions = 0; for (auto &Entry : Statistics) { PerFunctionStats &Stats = Entry.getValue(); - unsigned TotalVars = Stats.VarsInFunction.size() * Stats.NumFnInlined; + unsigned TotalVars = Stats.VarsInFunction.size() * (Stats.NumFnInlined + 1); unsigned Constants = Stats.ConstantMembers; VarWithLoc += Stats.TotalVarWithLoc + Constants; - VarTotal += TotalVars + Constants; + VarTotal += TotalVars; VarUnique += Stats.VarsInFunction.size(); LLVM_DEBUG(for (auto &V : Stats.VarsInFunction) llvm::dbgs() << Entry.getKey() << ": " << V.getKey() << "\n");