This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by krisb on Dec 5 2019, 9:37 AM.

Details

Summary

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.

Event Timeline

krisb created this revision.Dec 5 2019, 9:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2019, 9:37 AM
aprantl accepted this revision.Dec 5 2019, 9:44 AM

That sounds reasonable to me.

This revision is now accepted and ready to land.Dec 5 2019, 9:44 AM
djtodoro accepted this revision.Dec 5 2019, 11:39 PM

LGTM as well, thanks!

Please update the llvm/docs/CommandGuide/llvm-locstats.rst with the newest output.

Hm, the bucket name ‘>0-9%' does not look nice to me as well.

krisb added a comment.Dec 8 2019, 4:33 AM

@djtodoro , yeah, it doesn't look good.
I also considered an option to rename the first bucket to smth like "No location info" or "Not covered" or something similar then the second can be safely named '0-9%'.
Or simply to use '0-9%' together with '0%' which might be a bit unclear, but as docs say 'The line 0% shows the number and the percentage of DIEs with no location information', it should not be confusing.

@djtodoro , yeah, it doesn't look good.
I also considered an option to rename the first bucket to smth like "No location info" or "Not covered" or something similar then the second can be safely named '0-9%'.
Or simply to use '0-9%' together with '0%' which might be a bit unclear, but as docs say 'The line 0% shows the number and the percentage of DIEs with no location information', it should not be confusing.

does this bucket include 9%? I guess the next bucket starts at 10%, so 0-9 includes 9.99%? so technically this one is (0, 10)% and the next one is [10, 91)% etc... (or I guess you could put the % inside the braces/parens)? but that might be insufficiently obvious to read?

@djtodoro , yeah, it doesn't look good.
I also considered an option to rename the first bucket to smth like "No location info" or "Not covered" or something similar then the second can be safely named '0-9%'.
Or simply to use '0-9%' together with '0%' which might be a bit unclear, but as docs say 'The line 0% shows the number and the percentage of DIEs with no location information', it should not be confusing.

does this bucket include 9%? I guess the next bucket starts at 10%, so 0-9 includes 9.99%? so technically this one is (0, 10)% and the next one is [10, 91)% etc... (or I guess you could put the % inside the braces/parens)? but that might be insufficiently obvious to read?

I am also thinking about combination of the [/] and (/). That will clarify things here.

krisb added a comment.Dec 9 2019, 3:12 AM

@dblaikie , @djtodoro sorry for paying so much attention to details here, but does this one work with you?

     cov%          samples       percentage(~)
-------------------------------------------------
   0%                    1              16%
   ( 0, 10%)             0               0%
   [10, 20%)             0               0%
   [20, 30%)             0               0%
   [30, 40%)             0               0%
   [40, 50%)             0               0%
   [50, 60%)             1              16%
   [60, 70%)             0               0%
   [70, 80%)             0               0%
   [80, 90%)             1              16%
   [90,100%)             0               0%
   100%                  3              50%

And just mention here how the previously suggested option looks like:

      cov%          samples       percentage(~)
-------------------------------------------------
   No location info      1              16%
   0-9%                  0               0%
   10-19%                0               0%
   20-29%                0               0%
   30-39%                0               0%
   40-49%                0               0%
   50-59%                1              16%
   60-69%                0               0%
   70-79%                0               0%
   80-89%                1              16%
   90-99%                0               0%
   100%                  3              50%

@krisb Thanks for this again. First option seems better to me.

(Just please make sure, when we decide the final look, the docs gets updated accordingly.)

either looks OK to me - between those two, yeah, the ()[)/etc (the first) version is probably better. But I'll leave it to other folks more invested in statistics to make the final call.

@djtodoro , @dblaikie thanks for your opinions! I created a separate review for this change https://reviews.llvm.org/D71366. Please, take a look if you have a chance.

This one should be rebased on top of the D71366.

krisb updated this revision to Diff 233570.Dec 12 2019, 3:59 AM

Updated the doc, rebased on D71366.

krisb edited the summary of this revision. (Show Details)Dec 12 2019, 4:01 AM
This revision was automatically updated to reflect the committed changes.
spatel added a subscriber: spatel.EditedDec 13 2019, 7:07 AM

I'm seeing test failures on trunk after this commit:

FAIL: LLVM :: tools/llvm-locstats/locstats.ll (33082 of 34788)
******************** TEST 'LLVM :: tools/llvm-locstats/locstats.ll' FAILED ********************
Script:
--
: 'RUN: at line 3';   /Users/spatel/GitHub/llvm-project/release/bin/llc /Users/spatel/GitHub/llvm-project/llvm/test/tools/llvm-locstats/locstats.ll -o /Users/spatel/GitHub/llvm-project/release/test/tools/llvm-locstats/Output/locstats.ll.tmp0.o -filetype=obj
: 'RUN: at line 4';   '/usr/bin/python' /Users/spatel/GitHub/llvm-project/release/./bin/llvm-locstats /Users/spatel/GitHub/llvm-project/release/test/tools/llvm-locstats/Output/locstats.ll.tmp0.o | /Users/spatel/GitHub/llvm-project/release/bin/FileCheck /Users/spatel/GitHub/llvm-project/llvm/test/tools/llvm-locstats/locstats.ll --check-prefix=LOCSTATS
--
Exit Code: 2

Command Output (stderr):
--
Traceback (most recent call last):
  File "/Users/spatel/GitHub/llvm-project/release/./bin/llvm-locstats", line 212, in <module>
    Main()
  File "/Users/spatel/GitHub/llvm-project/release/./bin/llvm-locstats", line 190, in Main
    variables_coverage_map[cov_bucket] = json_parsed[cov_category]
KeyError: 'variables with [1%,10%) of its scope covered'
FileCheck error: '-' is empty.
FileCheck command line:  /Users/spatel/GitHub/llvm-project/release/bin/FileCheck /Users/spatel/GitHub/llvm-project/llvm/test/tools/llvm-locstats/locstats.ll --check-prefix=LOCSTATS
krisb added a comment.Dec 13 2019, 7:52 AM

@spatel thanks for reporting this!
Could you, please, check that llvm-locstat wasn't cached in the build/install directory? llvm-locstat should look for a variables with (0%,10%) of its scope covered as was changed by the patch, so I guess it didn't get updated for some reason.

@spatel thanks for reporting this!
Could you, please, check that llvm-locstat wasn't cached in the build/install directory? llvm-locstat should look for a variables with (0%,10%) of its scope covered as was changed by the patch, so I guess it didn't get updated for some reason.

That might've been it. I just rebuilt everything, and no more fails. Sorry for the noise.