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; } @@ -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");