[PATCH] D77441: [llvm-dwarfdump] Fix statistics for "vars"

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 17:21:39 PDT 2020


vsk created this revision.
vsk added reviewers: aprantl, djtodoro.
Herald added a subscriber: MaskRay.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.

In llvm-dwwarfdump --statistics output, "vars" refers to parameters and
local variables. Fix an issue where the scope bytes covered metric for
"vars" is unexpectedly low because parameter coverage isn't included.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77441

Files:
  llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
  llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test
  llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test
  llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
  llvm/tools/llvm-dwarfdump/Statistics.cpp


Index: llvm/tools/llvm-dwarfdump/Statistics.cpp
===================================================================
--- llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -322,7 +322,8 @@
           std::min(BytesInScope, BytesCovered);
       GlobalStats.ParamScopeBytes += BytesInScope;
       GlobalStats.ParamScopeEntryValueBytesCovered += BytesEntryValuesCovered;
-    } else if (IsVariable) {
+    }
+    if (IsParam || IsVariable) {
       GlobalStats.VarScopeBytesCovered += std::min(BytesInScope, BytesCovered);
       GlobalStats.VarScopeBytes += BytesInScope;
       GlobalStats.VarScopeEntryValueBytesCovered += BytesEntryValuesCovered;
@@ -528,7 +529,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 = 4;
+  unsigned Version = 5;
   unsigned VarParamTotal = 0;
   unsigned VarParamUnique = 0;
   unsigned VarParamWithLoc = 0;
Index: llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
+++ llvm/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":4
+; CHECK: "version":5
 
 ; namespace test {
 ;  extern int a;
Index: llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test
+++ llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test
@@ -64,7 +64,7 @@
 # }
 #
 
-CHECK: "version":4
+CHECK: "version":5
 CHECK: "source functions":3
 CHECK: "source functions with location":3
 CHECK: "inlined functions":8
Index: llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test
+++ llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test
@@ -69,7 +69,7 @@
 # }
 #
 
-CHECK: "version":4
+CHECK: "version":5
 CHECK: "source functions":3
 CHECK: "source functions with location":3
 CHECK: "inlined functions":7
Index: llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
+++ llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
@@ -5,9 +5,9 @@
 ; CHECK: "formal params scope bytes total":20
 ; CHECK: "formal params scope bytes covered":20
 ; CHECK: "formal params entry value scope bytes covered":5
-; CHECK: "vars scope bytes total":90
-; CHECK: "vars scope bytes covered":60
-; CHECK: "vars entry value scope bytes covered":0
+; CHECK: "vars scope bytes total":110
+; CHECK: "vars scope bytes covered":80
+; CHECK: "vars entry value scope bytes covered":5
 ; CHECK: "total variables procesed by location statistics":6
 ; CHECK: "variables with 0% of its scope covered":1
 ; CHECK: "variables with (0%,10%) of its scope covered":0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77441.254952.patch
Type: text/x-patch
Size: 3117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200404/bbdcc9e5/attachment.bin>


More information about the llvm-commits mailing list