[llvm] d5655c4 - [llvm-dwarfdump][Statistics] Don't count coverage less than 1% as 0%

Kristina Bessonova via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 06:35:58 PST 2019


Author: Kristina Bessonova
Date: 2019-12-13T17:34:58+03:00
New Revision: d5655c4d2e180b7eadb567ebf7e9a9393dec1355

URL: https://github.com/llvm/llvm-project/commit/d5655c4d2e180b7eadb567ebf7e9a9393dec1355
DIFF: https://github.com/llvm/llvm-project/commit/d5655c4d2e180b7eadb567ebf7e9a9393dec1355.diff

LOG: [llvm-dwarfdump][Statistics] Don't count coverage less than 1% as 0%

Summary:
This is a follow up for D70548.
Currently, variables with debug info coverage between 0% and 1% are put into
zero-bucket. D70548 changed the way statistics calculate a variable's coverage:
we began to use enclosing scope rather than a possible variable life range.
Thus more variables might be moved to zero-bucket despite they have some debug
info coverage.
The patch is to distinguish between a variable that has location info but
it's significantly less than its enclosing scope and a variable that doesn't
have it at all.

Reviewers: djtodoro, aprantl, dblaikie, avl

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71070

Added: 
    

Modified: 
    llvm/docs/CommandGuide/llvm-locstats.rst
    llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
    llvm/test/tools/llvm-locstats/locstats.ll
    llvm/tools/llvm-dwarfdump/Statistics.cpp
    llvm/utils/llvm-locstats/llvm-locstats.py

Removed: 
    


################################################################################
diff  --git a/llvm/docs/CommandGuide/llvm-locstats.rst b/llvm/docs/CommandGuide/llvm-locstats.rst
index 4f86522c9ed0..1d05c0cf82b1 100644
--- a/llvm/docs/CommandGuide/llvm-locstats.rst
+++ b/llvm/docs/CommandGuide/llvm-locstats.rst
@@ -55,7 +55,7 @@ OUTPUT EXAMPLE
         cov%          samples       percentage(~)
   -------------------------------------------------
      0%                    1              16%
-     [1%,10%)              0               0%
+     (0%,10%)              0               0%
      [10%,20%)             0               0%
      [20%,30%)             0               0%
      [30%,40%)             0               0%

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/locstats.ll b/llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
index 598d1b79e13b..7521806c624f 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
+++ b/llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
@@ -10,7 +10,7 @@
 ; CHECK: "vars entry value scope bytes covered":0
 ; CHECK: "total variables procesed by location statistics":6
 ; CHECK: "variables with 0% of its scope covered":1
-; CHECK: "variables with [1%,10%) of its scope covered":0
+; CHECK: "variables with (0%,10%) of its scope covered":0
 ; CHECK: "variables with [10%,20%) of its scope covered":0
 ; CHECK: "variables with [20%,30%) of its scope covered":0
 ; CHECK: "variables with [30%,40%) of its scope covered":0
@@ -22,7 +22,7 @@
 ; CHECK: "variables with [90%,100%) of its scope covered":0
 ; CHECK: "variables with 100% of its scope covered":3
 ; CHECK: "variables (excluding the debug entry values) with 0% of its scope covered":1
-; CHECK: "variables (excluding the debug entry values) with [1%,10%) of its scope covered":0
+; CHECK: "variables (excluding the debug entry values) with (0%,10%) of its scope covered":0
 ; CHECK: "variables (excluding the debug entry values) with [10%,20%) of its scope covered":0
 ; CHECK: "variables (excluding the debug entry values) with [20%,30%) of its scope covered":0
 ; CHECK: "variables (excluding the debug entry values) with [30%,40%) of its scope covered":0
@@ -35,7 +35,7 @@
 ; CHECK: "variables (excluding the debug entry values) with 100% of its scope covered":2
 ; CHECK: "total params procesed by location statistics":2
 ; CHECK: "params with 0% of its scope covered":0
-; CHECK: "params with [1%,10%) of its scope covered":0
+; CHECK: "params with (0%,10%) of its scope covered":0
 ; CHECK: "params with [10%,20%) of its scope covered":0
 ; CHECK: "params with [20%,30%) of its scope covered":0
 ; CHECK: "params with [30%,40%) of its scope covered":0
@@ -47,7 +47,7 @@
 ; CHECK: "params with [90%,100%) of its scope covered":0
 ; CHECK: "params with 100% of its scope covered":2
 ; CHECK: "params (excluding the debug entry values) with 0% of its scope covered":0
-; CHECK: "params (excluding the debug entry values) with [1%,10%) of its scope covered":0
+; CHECK: "params (excluding the debug entry values) with (0%,10%) of its scope covered":0
 ; CHECK: "params (excluding the debug entry values) with [10%,20%) of its scope covered":0
 ; CHECK: "params (excluding the debug entry values) with [20%,30%) of its scope covered":0
 ; CHECK: "params (excluding the debug entry values) with [30%,40%) of its scope covered":0
@@ -60,7 +60,7 @@
 ; CHECK: "params (excluding the debug entry values) with 100% of its scope covered":1
 ; CHECK: "total vars procesed by location statistics":4
 ; CHECK: "vars with 0% of its scope covered":1
-; CHECK: "vars with [1%,10%) of its scope covered":0
+; CHECK: "vars with (0%,10%) of its scope covered":0
 ; CHECK: "vars with [10%,20%) of its scope covered":0
 ; CHECK: "vars with [20%,30%) of its scope covered":0
 ; CHECK: "vars with [30%,40%) of its scope covered":0
@@ -72,7 +72,7 @@
 ; CHECK: "vars with [90%,100%) of its scope covered":0
 ; CHECK: "vars with 100% of its scope covered":1
 ; CHECK: "vars (excluding the debug entry values) with 0% of its scope covered":1
-; CHECK: "vars (excluding the debug entry values) with [1%,10%) of its scope covered":0
+; CHECK: "vars (excluding the debug entry values) with (0%,10%) of its scope covered":0
 ; CHECK: "vars (excluding the debug entry values) with [10%,20%) of its scope covered":0
 ; CHECK: "vars (excluding the debug entry values) with [20%,30%) of its scope covered":0
 ; CHECK: "vars (excluding the debug entry values) with [30%,40%) of its scope covered":0

diff  --git a/llvm/test/tools/llvm-locstats/locstats.ll b/llvm/test/tools/llvm-locstats/locstats.ll
index 77621b24212a..e267b7eeb1f9 100644
--- a/llvm/test/tools/llvm-locstats/locstats.ll
+++ b/llvm/test/tools/llvm-locstats/locstats.ll
@@ -5,7 +5,7 @@
 ;
 ; Test the llvm-locstats output.
 ; LOCSTATS: 0% 0 0%
-; LOCSTATS: [1%,10%) 0 0%
+; LOCSTATS: (0%,10%) 0 0%
 ; LOCSTATS: [10%,20%) 0 0%
 ; LOCSTATS: [20%,30%) 1 11%
 ; LOCSTATS: [30%,40%) 0 0%

diff  --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
index 2d0f30476e3e..5bef4d5148ca 100644
--- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -138,18 +138,16 @@ static void collectLocStats(uint64_t BytesCovered, uint64_t BytesInScope,
                             std::vector<unsigned> &VarLocStats, bool IsParam,
                             bool IsLocalVar) {
   auto getCoverageBucket = [BytesCovered, BytesInScope]() -> unsigned {
-    unsigned LocBucket = 100 * (double)BytesCovered / BytesInScope;
-    if (LocBucket == 0) {
-      // No debug location at all for the variable.
+    // No debug location at all for the variable.
+    if (BytesCovered == 0)
       return 0;
-    } else if (LocBucket == 100 || BytesCovered > BytesInScope) {
-      // Fully covered variable within its scope.
+    // Fully covered variable within its scope.
+    if (BytesCovered >= BytesInScope)
       return NumOfCoverageCategories - 1;
-    } else {
-      // Get covered range (e.g. 20%-29%).
-      LocBucket /= 10;
-      return LocBucket + 1;
-    }
+    // Get covered range (e.g. 20%-29%).
+    unsigned LocBucket = 100 * (double)BytesCovered / BytesInScope;
+    LocBucket /= 10;
+    return LocBucket + 1;
   };
 
   unsigned CoverageBucket = getCoverageBucket();
@@ -430,9 +428,9 @@ static void printLocationStats(raw_ostream &OS,
      << LocationStats[0];
   LLVM_DEBUG(llvm::dbgs() << Key << " with 0% of its scope covered: "
                           << LocationStats[0] << '\n');
-  OS << ",\"" << Key << " with [1%,10%) of its scope covered\":"
+  OS << ",\"" << Key << " with (0%,10%) of its scope covered\":"
      << LocationStats[1];
-  LLVM_DEBUG(llvm::dbgs() << Key << " with [1%,10%) of its scope covered: "
+  LLVM_DEBUG(llvm::dbgs() << Key << " with (0%,10%) of its scope covered: "
                           << LocationStats[1] << '\n');
   for (unsigned i = 2; i < NumOfCoverageCategories - 1; ++i) {
     OS << ",\"" << Key << " with [" << (i - 1) * 10 << "%," << i * 10

diff  --git a/llvm/utils/llvm-locstats/llvm-locstats.py b/llvm/utils/llvm-locstats/llvm-locstats.py
index 2bbc3f1986d8..0d177ef294e5 100755
--- a/llvm/utils/llvm-locstats/llvm-locstats.py
+++ b/llvm/utils/llvm-locstats/llvm-locstats.py
@@ -15,7 +15,7 @@
 
 def coverage_buckets():
   yield '0%'
-  yield '[1%,10%)'
+  yield '(0%,10%)'
   for start in range(10, 91, 10):
     yield '[{0}%,{1}%)'.format(start, start + 10)
   yield '100%'


        


More information about the llvm-commits mailing list