This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov
ClosedPublic

Authored by calixte on Sep 13 2018, 7:17 AM.

Details

Summary

These options are taking regex separated by colons to filter files.

  • if both are empty then all files are instrumented
  • if -fprofile-filter-files is empty then all the filenames matching any of the regex from exclude are not instrumented
  • if -fprofile-exclude-files is empty then all the filenames matching any of the regex from filter are instrumented
  • if both aren't empty then all the filenames which match any of the regex in filter and which don't match all the regex in filter are instrumented
  • this patch is a follow-up of https://reviews.llvm.org/D52033

Diff Detail

Event Timeline

calixte created this revision.Sep 13 2018, 7:17 AM
vsk added a comment.Sep 13 2018, 12:37 PM

Please document the filter behavior (see docs/UsersManual.rst).

include/clang/Driver/CC1Options.td
236 ↗(On Diff #165279)

Have you checked whether gcc supports similar options? If so, it would be great if we could match their name & behavior.

calixte added inline comments.Sep 13 2018, 1:38 PM
include/clang/Driver/CC1Options.td
236 ↗(On Diff #165279)

The only one I found -finstrument-functions-exclude-file-list (https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html).
But no regex and no way to include one file only.
I took the names from gcovr: https://manpages.debian.org/jessie/gcovr/gcovr.1.en.html

marco-c added inline comments.Sep 20 2018, 2:04 AM
include/clang/Driver/CC1Options.td
236 ↗(On Diff #165279)

We could file a bug in GCC's Bugzilla and agree with them about the options.

vsk added inline comments.Sep 20 2018, 4:18 PM
test/CodeGen/code-coverage-filter.c
5

Could you use more descriptive check prefixes here, like 'NO-HEADERS'? Also, if it's possible to use fewer '\' escape tokens by wrapping the regex list in single-quotes, that would make things easier to read.

33
  1. This test will break on bots which use 16-bit ints. For simplicity, consider sticking to void and getting rid of unnecessary control flow.
  2. Is there any need to check '#0'?
vsk added inline comments.Sep 20 2018, 4:33 PM
include/clang/Driver/CC1Options.td
236 ↗(On Diff #165279)

+ 1, I think it's a great idea to loop in some gcc developers.

calixte updated this revision to Diff 167101.Sep 26 2018, 4:17 AM

Fix tests

I reported a bug for gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87442
@vsk I'd like to add documentation in Docs/UsersManual.rst, but I've no idea on what's a good place for this (I look for option -coverage-no-function-names-in-data, but I didn't get anything). So could you give a me a clue please ?

@vsk, gcc guys are ok for -fprofile-filter-files and -fprofile-exclude-files, are you ok with that ?
Should these options prefixed by -Xclang or not ?

vsk added a comment.Oct 25 2018, 9:58 AM

@vsk, gcc guys are ok for -fprofile-filter-files and -fprofile-exclude-files, are you ok with that ?

That sounds fine to me.

Should these options prefixed by -Xclang or not ?

I don't think they should be. These options should be easy to surface to users.

vsk added a comment.Oct 25 2018, 10:01 AM

Thank you!

@vsk I'd like to add documentation in Docs/UsersManual.rst, but I've no idea on what's a good place for this (I look for option -coverage-no-function-names-in-data, but I didn't get anything). So could you give a me a clue please ?

That's the right file to edit. Please create a section for gcov-based profiling. I won't ask that you describe the entire gcov pipeline, but it would really help to have a description of the driver flags you're adding & some examples of how to use them.

calixte updated this revision to Diff 172752.Nov 6 2018, 6:18 AM

Change options names to -fprofile-exclude-files & -fprofile-filter-files and add some doc in UserManual.

calixte retitled this revision from [Clang] Add options -Xclang -coverage-filter and -Xclang -coverage-exclude to filter the files to instrument with gcov to [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to filter the files to instrument with gcov.Nov 6 2018, 6:19 AM
calixte edited the summary of this revision. (Show Details)
calixte updated this revision to Diff 172761.Nov 6 2018, 6:49 AM

Fix plural form of regex and just use ';' as separator.

calixte updated this revision to Diff 172905.Nov 7 2018, 12:52 AM

Update doc.

marco-c accepted this revision.Nov 7 2018, 1:21 AM
This revision is now accepted and ready to land.Nov 7 2018, 1:21 AM
vsk accepted this revision.Nov 7 2018, 3:23 PM

Can be done in a new commit but I think this should be mentioned in the clang release notes.

calixte updated this revision to Diff 173622.Nov 12 2018, 12:47 AM

Update ReleaseNotes

calixte updated this revision to Diff 173623.Nov 12 2018, 12:50 AM

Forgot the ellipsis in the release notes.

This revision was automatically updated to reflect the committed changes.