diff --git a/llvm/test/tools/llvm-dwarfdump/X86/locstats.ll b/llvm/test/tools/llvm-dwarfdump/X86/locstats.ll --- 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-9% of its scope covered":0 +; CHECK: "variables with >0-9% of its scope covered":0 ; CHECK: "variables with 10-19% of its scope covered":0 ; CHECK: "variables with 20-29% of its scope covered":0 ; CHECK: "variables with 30-39% of its scope covered":0 @@ -22,7 +22,7 @@ ; CHECK: "variables with 90-99% 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-9% of its scope covered":0 +; CHECK: "variables (excluding the debug entry values) with >0-9% of its scope covered":0 ; CHECK: "variables (excluding the debug entry values) with 10-19% of its scope covered":0 ; CHECK: "variables (excluding the debug entry values) with 20-29% of its scope covered":0 ; CHECK: "variables (excluding the debug entry values) with 30-39% 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-9% of its scope covered":0 +; CHECK: "params with >0-9% of its scope covered":0 ; CHECK: "params with 10-19% of its scope covered":0 ; CHECK: "params with 20-29% of its scope covered":0 ; CHECK: "params with 30-39% of its scope covered":0 @@ -47,7 +47,7 @@ ; CHECK: "params with 90-99% 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-9% of its scope covered":0 +; CHECK: "params (excluding the debug entry values) with >0-9% of its scope covered":0 ; CHECK: "params (excluding the debug entry values) with 10-19% of its scope covered":0 ; CHECK: "params (excluding the debug entry values) with 20-29% of its scope covered":0 ; CHECK: "params (excluding the debug entry values) with 30-39% 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-9% of its scope covered":0 +; CHECK: "vars with >0-9% of its scope covered":0 ; CHECK: "vars with 10-19% of its scope covered":0 ; CHECK: "vars with 20-29% of its scope covered":0 ; CHECK: "vars with 30-39% of its scope covered":0 @@ -72,7 +72,7 @@ ; CHECK: "vars with 90-99% 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-9% of its scope covered":0 +; CHECK: "vars (excluding the debug entry values) with >0-9% of its scope covered":0 ; CHECK: "vars (excluding the debug entry values) with 10-19% of its scope covered":0 ; CHECK: "vars (excluding the debug entry values) with 20-29% of its scope covered":0 ; CHECK: "vars (excluding the debug entry values) with 30-39% of its scope covered":0 diff --git a/llvm/test/tools/llvm-locstats/locstats.ll b/llvm/test/tools/llvm-locstats/locstats.ll --- 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-9% 0 0% +; LOCSTATS: >0-9% 0 0% ; LOCSTATS: 10-19% 0 0% ; LOCSTATS: 20-29% 1 11% ; LOCSTATS: 30-39% 0 0% diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp --- a/llvm/tools/llvm-dwarfdump/Statistics.cpp +++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp @@ -138,18 +138,16 @@ std::vector &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 @@ << LocationStats[0]; LLVM_DEBUG(llvm::dbgs() << Key << " with 0% of its scope covered: " << LocationStats[0] << '\n'); - OS << ",\"" << Key << " with 1-9% of its scope covered\":" + OS << ",\"" << Key << " with >0-9% of its scope covered\":" << LocationStats[1]; - LLVM_DEBUG(llvm::dbgs() << Key << " with 1-9% of its scope covered: " + LLVM_DEBUG(llvm::dbgs() << Key << " with >0-9% of its scope covered: " << LocationStats[1] << '\n'); for (unsigned i = 2; i < NumOfCoverageCategories - 1; ++i) { OS << ",\"" << Key << " with " << (i - 1) * 10 << "-" << i * 10 - 1 diff --git a/llvm/utils/llvm-locstats/llvm-locstats.py b/llvm/utils/llvm-locstats/llvm-locstats.py --- 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-9%' + yield '>0-9%' for start in range(10, 91, 10): yield '{0}-{1}%'.format(start, start + 9) yield '100%'