This change implements support for applying profile instrumentation
only to selected files or functions. The implementation uses the
sanitizer special case list format to select which files and functions
to instrument, and relies on the new noprofile IR attribute to exclude
functions from instrumentation.
Details
Diff Detail
Event Timeline
clang/docs/SourceBasedCodeCoverage.rst | ||
---|---|---|
77 | perhaps documenting how compiler generated functions are handled? | |
86 | what is the default section name? | |
clang/lib/CodeGen/CodeGenModule.cpp | ||
2569 | Should the option to turn on instrumentation also be checked? | |
2591 | If the profile list contains only one line of exclude list, it seems that all functions will be rejected as the function returns 'false' by default for all other functions? | |
clang/lib/CodeGen/CodeGenModule.h | ||
1280 | Document the method and params. |
clang/docs/SourceBasedCodeCoverage.rst | ||
---|---|---|
86 | It's * which always matches. | |
clang/lib/CodeGen/CodeGenModule.cpp | ||
2569 | Currently, this method is only invoked from CodeGenFunction which does its own check, but I'm happy to include a check here in case there are ever other callers. | |
2591 | That's correct, would you expect a different behavior and if so what should that behavior be? Currently, the profile list is used to build up a list of functions and files that should be instrumented. Any function or file that's not covered by the profile list is automatically excluded (not included may be more correct). Having just excludes without any includes means that nothing will be instrumented. |
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
2591 | It is natural and more useful to let user simply specify exclude lists so they don't need to worry about patterns of other functions to be instrumented. This means that when only exclude list is specified, the default should be flipped to be true (instrument everything else). If there only include list, the default is false. If there are both, the include list should be used to specify a super set while the exclude list (taking precedence) used to specify a subset from the super set. |
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
2591 | That makes sense, I've implemented that in the latest patch. |
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
851 | If we add an instrumentation kind, it may be more convenient to trigger a -Wcovered-switch warning (by removing this default case) vs. seeing a crash at runtime. |
clang/lib/CodeGen/CodeGenFunction.cpp | ||
---|---|---|
851 | Done, I've also decided to move the helper function inside the ProfileList class to hide the detail of how ProfileInstrKind translates to section name. |
clang/test/CodeGen/profile-filter.c | ||
---|---|---|
17 | Can you add a test case with both include and exclude list (the intersection of INCLUDE_SET & !EXCLUDE_SET)? |
clang/test/CodeGen/profile-filter.c | ||
---|---|---|
17 | See the case above this one which has: fun:test* !fun:test1 Is that what you have in mind? |
clang/test/CodeGen/profile-filter.c | ||
---|---|---|
17 | Right |
clang/test/CodeGen/profile-filter.c | ||
---|---|---|
17 | Do we need to do anything then since this test case already exists? |
Looks like this breaks tests on windows: http://45.33.8.238/win/32075/step_7.txt
Please take a look, and revert for now if it takes a while to fix.
Thanks for the heads up, I suspect it might be because of the Windows paths in the list file. I've reverted the change so I can test the fix on Windows before relanding.
clang/docs/UsersManual.rst | ||
---|---|---|
2271 ↗ | (On Diff #319359) | This can be added below -fprofile-exclude-files= |
clang/docs/UsersManual.rst | ||
---|---|---|
2271 ↗ | (On Diff #319359) | I considered it but that's in the GCOV section and this flag only applies to the LLVM instrumentation. |
perhaps documenting how compiler generated functions are handled?