diff options
author | Indu Bhagat <indu.bhagat@oracle.com> | 2018-09-26 22:29:54 +0000 |
---|---|---|
committer | Qing Zhao <qinzhao@gcc.gnu.org> | 2018-09-26 22:29:54 +0000 |
commit | bc162b0e6f9af9b03441e0e2b85ba0a98e4e5314 (patch) | |
tree | 55efbf771f6510f27e17ff5967320a448be1a27a /gcc/coverage.c | |
parent | 8313a7643a2cf5f0037e08f4e6a6d7002aeef8a0 (diff) | |
download | gcc-bc162b0e6f9af9b03441e0e2b85ba0a98e4e5314.zip gcc-bc162b0e6f9af9b03441e0e2b85ba0a98e4e5314.tar.gz gcc-bc162b0e6f9af9b03441e0e2b85ba0a98e4e5314.tar.bz2 |
re PR gcov-profile/86957 (gcc should warn about missing profiles for a compilation unit or a new function with -fprofile-use)
2018-09-26 Indu Bhagat <indu.bhagat@oracle.com>
PR gcov-profile/86957
* common.opt: New warning option -Wmissing-profile.
* coverage.c (get_coverage_counts): Add warning for missing .gcda file.
* doc/invoke.texi: Document -Wmissing-profile.
From-SVN: r264657
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r-- | gcc/coverage.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c index 8f12778..19c696c 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -304,16 +304,23 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum, { static int warned = 0; - if (!warned++ && dump_enabled_p ()) + if (!warned++) { - dump_user_location_t loc - = dump_user_location_t::from_location_t (input_location); - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + warning (OPT_Wmissing_profile, + "%qs profile count data file not found", + da_file_name); + if (dump_enabled_p ()) + { + dump_user_location_t loc + = dump_user_location_t::from_location_t (input_location); + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, + "file %s not found\n", + da_file_name); + dump_printf (MSG_OPTIMIZED_LOCATIONS, (flag_guess_branch_prob - ? "file %s not found, execution counts estimated\n" - : "file %s not found, execution counts assumed to " - "be zero\n"), - da_file_name); + ? "execution counts estimated\n" + : "execution counts assumed to be zero\n")); + } } return NULL; } @@ -327,10 +334,17 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum, elt.ctr = counter; entry = counts_hash->find (&elt); if (!entry) - /* The function was not emitted, or is weak and not chosen in the - final executable. Silently fail, because there's nothing we - can do about it. */ - return NULL; + { + if (counter == GCOV_COUNTER_ARCS) + warning_at (DECL_SOURCE_LOCATION (current_function_decl), + OPT_Wmissing_profile, + "profile for function %qD not found in profile data", + current_function_decl); + /* The function was not emitted, or is weak and not chosen in the + final executable. Silently fail, because there's nothing we + can do about it. */ + return NULL; + } if (entry->cfg_checksum != cfg_checksum) { |