This is an archive of the discontinued LLVM Phabricator instance.

[SanitizerCoverage] Implement user-friendly -fsanitize-coverage= flags.
ClosedPublic

Authored by samsonov on May 7 2015, 2:17 PM.

Details

Summary

Possible coverage levels are:

  • -fsanitize-coverage=func - function-level coverage
  • -fsanitize-coverage=bb - basic-block-level coverage
  • -fsanitize-coverage=edge - edge-level coverage

Extra features are:

  • -fsanitize-coverage=indirect-calls - coverage for indirect calls
  • -fsanitize-coverage=trace-bb - tracing for basic blocks
  • -fsanitize-coverage=trace-cmp - tracing for cmp instructions
  • -fsanitize-coverage=8bit-counters - frequency counters

Levels and features can be combined in comma-separated list, and
can be disabled by subsequent -fno-sanitize-coverage= flags, e.g.:

-fsanitize-coverage=bb,trace-bb,8bit-counters -fno-sanitize-coverage=trace-bb

is equivalient to:

-fsanitize-coverage=bb,8bit-counters

Original semantics of -fsanitize-coverage flag is preserved:

  • -fsanitize-coverage=0 disables the coverage
  • -fsanitize-coverage=1 is a synonym for -fsanitize-coverage=func
  • -fsanitize-coverage=2 is a synonym for -fsanitize-coverage=bb
  • -fsanitize-coverage=3 is a synonym for -fsanitize-coverage=edge
  • -fsanitize-coverage=4 is a synonym for -fsanitize-coverage=edge,indirect-calls

Driver tries to diagnose invalid flag usage, in particular:

  • At most one level (func,bb,edge) must be specified.
  • "trace-bb" and "8bit-counters" features require some level to be specified.

See test case for more examples.

Diff Detail

Repository
rL LLVM

Event Timeline

samsonov updated this revision to Diff 25236.May 7 2015, 2:17 PM
samsonov retitled this revision from to [SanitizerCoverage] Implement user-friendly -fsanitize-coverage= flags..
samsonov updated this object.
samsonov edited the test plan for this revision. (Show Details)
samsonov added a reviewer: kcc.
samsonov added a subscriber: Unknown Object (MLST).
samsonov updated this object.May 7 2015, 2:18 PM
kcc accepted this revision.May 7 2015, 2:38 PM
kcc edited edge metadata.

LGTM++

This revision is now accepted and ready to land.May 7 2015, 2:38 PM
This revision was automatically updated to reflect the committed changes.