This is an archive of the discontinued LLVM Phabricator instance.

[Coverage] Add an option to emit limited coverage info
ClosedPublic

Authored by vsk on Sep 20 2017, 4:09 PM.

Details

Summary

Add an option to emit limited coverage info for unused decls. It's just a cl::opt for now to allow us to experiment quickly.

When building llc, this results in an 84% size reduction in the llvm_covmap section, and a similar size reduction in the llvm_prf_names section. In practice I expect the size reduction to be roughly quadratic with the size of the program.

The downside is that coverage for headers will no longer be complete. This will make the line/function/region coverage metrics incorrect, since they will be artificially high. One solution would be to somehow disable those metrics when using limited-coverage=true.

This is related to: llvm.org/PR34533 (make SourceBasedCodeCoverage scale)

Diff Detail

Repository
rL LLVM

Event Timeline

vsk created this revision.Sep 20 2017, 4:09 PM

I don't like the flag name, but it's bike-shedding

Dor1s accepted this revision.Sep 20 2017, 5:17 PM

Thanks Vedant!

This revision is now accepted and ready to land.Sep 20 2017, 5:17 PM
vsk added a comment.Sep 20 2017, 5:30 PM

Thanks for taking a look. I'd like to give Alex and others a chance to read over this (different timezones), and am happy to change the name of the cl::opt.

kcc added a comment.Sep 20 2017, 5:34 PM

naming is hard. Maybe something like

-mllvm -clang-coverage-experimental-ignore-headers=1 ?

(anyway, bike-shedding...)

arphaman accepted this revision.Sep 21 2017, 8:11 AM

This makes sense.

The downside is that coverage for headers will no longer be complete. This will make the line/function/region coverage metrics incorrect, since they will be artificially high. One solution would be to somehow disable those metrics when using limited-coverage=true.

What about:

  1. Lazy idea: Put up a * marking and add a note in the footnotes of the HTML that says that the metrics don't include unused functions.
  1. Crazy idea: use unique header detection that's used by index-while-building to emit coverage mapping for unique headers only (You could potentially embed it into indexer's records as well). This will definitely save a bunch of space as you'll have one set of coverage mapping for a function from a header and will preserve empty coverage for unused functions, but will require obvious changes to llvm-cov and the whole coverage embedded in the executable paradigm.
This revision was automatically updated to reflect the committed changes.