diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/common.opt | 4 | ||||
-rw-r--r-- | gcc/coverage.c | 14 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 19 |
4 files changed, 42 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2901b2f..74dbeeb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -3,6 +3,13 @@ PR rtl-optimization/94605 * early-remat.c (early_remat::process_block): Handle insns that set multiple candidate registers. +2020-04-16 Jan Hubicka <hubicka@ucw.cz> + + PR gcov-profile/93401 + * common.opt (profile-prefix-path): New option. + * coverae.c: Include diagnostics.h. + (coverage_init): Strip profile prefix path. + * doc/invoke.texi (-fprofile-prefix-path): Document. 2020-04-16 Richard Biener <rguenther@suse.de> diff --git a/gcc/common.opt b/gcc/common.opt index bb2ea4c..1e604ba 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2196,6 +2196,10 @@ Enum(profile_update) String(atomic) Value(PROFILE_UPDATE_ATOMIC) EnumValue Enum(profile_update) String(prefer-atomic) Value(PROFILE_UPDATE_PREFER_ATOMIC) +fprofile-prefix-path= +Common Joined RejectNegative Var(profile_prefix_path) +Remove prefix from absolute path before manging name for -fprofile-generate= and -fprofile-use=. + fprofile-generate Common Enable common options for generating profile info for profile feedback directed optimizations. diff --git a/gcc/coverage.c b/gcc/coverage.c index 30ae84d..45c0278 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "intl.h" #include "auto-profile.h" #include "profile.h" +#include "diagnostic.h" #include "gcov-io.c" @@ -1221,6 +1222,19 @@ coverage_init (const char *filename) const char *separator = "/"; #endif filename = concat (getpwd (), separator, filename, NULL); + if (profile_prefix_path) + { + if (!strncmp (filename, profile_prefix_path, + strlen (profile_prefix_path))) + { + filename += strlen (profile_prefix_path); + while (*filename == *separator) + filename++; + } + else + warning (0, "filename %qs does not start with profile " + "prefix %qs", filename, profile_prefix_path); + } filename = mangle_path (filename); len = strlen (filename); } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3bb95ff..8b5cd82 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -549,8 +549,9 @@ Objective-C and Objective-C++ Dialects}. @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage @gol -fprofile-abs-path @gol -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol --fprofile-note=@var{path} -fprofile-update=@var{method} @gol --fprofile-filter-files=@var{regex} -fprofile-exclude-files=@var{regex} -fprofile-reproducibility @gol +-fprofile-note=@var{path} -fprofile-prefix-path=@var{path} @gol +-fprofile-update=@var{method} -fprofile-filter-files=@var{regex} @gol +-fprofile-exclude-files=@var{regex} -fprofile-reproducibility @gol -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} @gol -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... @gol -fsanitize-undefined-trap-on-error -fbounds-check @gol @@ -13400,6 +13401,20 @@ If @var{path} is specified, GCC saves @file{.gcno} file into @var{path} location. If you combine the option with multiple source files, the @file{.gcno} file will be overwritten. +@item -fprofile-prefix-path=@var{path} + +This option can be used in combination with +@option{profile-generate=}@var{profile_dir} and +@option{profile-use=}@var{profile_dir} to inform GCC where is the base +directory of built source tree. By default @var{profile_dir} will contain +files with mangled absolute paths of all object files in the built project. +This is not desirable when directory used to build the instrumented binary +differs from the directory used to build the binary optimized with profile +feedback because the profile data will not be found during the optimized build. +In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path} +pointing to the base directory of the build can be used to strip the irrelevant +part of the path and keep all file names relative to the main build directory. + @item -fprofile-update=@var{method} @opindex fprofile-update |