[PATCH] D57849: llvm-dwarfdump: Stop counting out-of-line subprogram in the "inlined functions" statistic.

Caroline Tice via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 7 11:02:46 PST 2019


cmtice updated this revision to Diff 185824.
cmtice added a comment.

This increases the version number, as requested.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57849/new/

https://reviews.llvm.org/D57849

Files:
  test/tools/llvm-dwarfdump/X86/statistics.ll
  test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll
  test/tools/llvm-dwarfdump/X86/stats-inlining-single-cu.ll
  tools/llvm-dwarfdump/Statistics.cpp


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");
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: 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/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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57849.185824.patch
Type: text/x-patch
Size: 3441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190207/6d80bef8/attachment.bin>


More information about the llvm-commits mailing list