aboutsummaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2014-07-26 00:06:56 +0000
committerXinliang David Li <davidxl@gcc.gnu.org>2014-07-26 00:06:56 +0000
commit2243ba513844565f5046055fe610f32df9f8876f (patch)
treeb55990283764ae89e23d3c97dc21584d42c7a7c0 /gcc/coverage.c
parent37545fa7226bfa3aa72244dd119a9a82ed26d077 (diff)
downloadgcc-2243ba513844565f5046055fe610f32df9f8876f.zip
gcc-2243ba513844565f5046055fe610f32df9f8876f.tar.gz
gcc-2243ba513844565f5046055fe610f32df9f8876f.tar.bz2
Make FDO more tolerant to source changes
From-SVN: r213068
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r--gcc/coverage.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 8ac1d5f..dd7655d 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -54,6 +54,7 @@ along with GCC; see the file COPYING3. If not see
#include "intl.h"
#include "filenames.h"
#include "target.h"
+#include "params.h"
#include "gcov-io.h"
#include "gcov-io.c"
@@ -369,8 +370,13 @@ get_coverage_counts (unsigned counter, unsigned expected,
da_file_name);
return NULL;
}
-
- elt.ident = current_function_funcdef_no + 1;
+ if (PARAM_VALUE (PARAM_PROFILE_FUNC_INTERNAL_ID))
+ elt.ident = current_function_funcdef_no + 1;
+ else
+ {
+ gcc_assert (coverage_node_map_initialized_p ());
+ elt.ident = cgraph_node::get (cfun->decl)->profile_id;
+ }
elt.ctr = counter;
entry = counts_hash->find (&elt);
if (!entry || !entry->summary.num)
@@ -416,7 +422,8 @@ get_coverage_counts (unsigned counter, unsigned expected,
}
else if (entry->lineno_checksum != lineno_checksum)
{
- warning (0, "source locations for function %qE have changed,"
+ warning (OPT_Wcoverage_mismatch,
+ "source locations for function %qE have changed,"
" the profile data may be out of date",
DECL_ASSEMBLER_NAME (current_function_decl));
}
@@ -581,12 +588,13 @@ coverage_compute_profile_id (struct cgraph_node *n)
{
expanded_location xloc
= expand_location (DECL_SOURCE_LOCATION (n->decl));
+ bool use_name_only = (PARAM_VALUE (PARAM_PROFILE_FUNC_INTERNAL_ID) == 0);
- chksum = xloc.line;
+ chksum = (use_name_only ? 0 : xloc.line);
chksum = coverage_checksum_string (chksum, xloc.file);
chksum = coverage_checksum_string
(chksum, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (n->decl)));
- if (first_global_object_name)
+ if (!use_name_only && first_global_object_name)
chksum = coverage_checksum_string
(chksum, first_global_object_name);
chksum = coverage_checksum_string
@@ -645,7 +653,15 @@ coverage_begin_function (unsigned lineno_checksum, unsigned cfg_checksum)
/* Announce function */
offset = gcov_write_tag (GCOV_TAG_FUNCTION);
- gcov_write_unsigned (current_function_funcdef_no + 1);
+ if (PARAM_VALUE (PARAM_PROFILE_FUNC_INTERNAL_ID))
+ gcov_write_unsigned (current_function_funcdef_no + 1);
+ else
+ {
+ gcc_assert (coverage_node_map_initialized_p ());
+ gcov_write_unsigned (
+ cgraph_node::get (current_function_decl)->profile_id);
+ }
+
gcov_write_unsigned (lineno_checksum);
gcov_write_unsigned (cfg_checksum);
gcov_write_string (IDENTIFIER_POINTER
@@ -682,8 +698,15 @@ coverage_end_function (unsigned lineno_checksum, unsigned cfg_checksum)
if (!DECL_EXTERNAL (current_function_decl))
{
item = ggc_alloc<coverage_data> ();
-
- item->ident = current_function_funcdef_no + 1;
+
+ if (PARAM_VALUE (PARAM_PROFILE_FUNC_INTERNAL_ID))
+ item->ident = current_function_funcdef_no + 1;
+ else
+ {
+ gcc_assert (coverage_node_map_initialized_p ());
+ item->ident = cgraph_node::get (cfun->decl)->profile_id;
+ }
+
item->lineno_checksum = lineno_checksum;
item->cfg_checksum = cfg_checksum;