Commit cb686b99 by Nathan Sidwell Committed by Nathan Sidwell

coverage.c (bbg_file_stamp): New.

	* coverage.c (bbg_file_stamp): New.
	(read_counts_file): Merge incoming stamp with bbg_file_stamp.
	(build_info): Write bbg_file_stamp.
	(coverage_init): Initialize bbg_file_stamp.  Read counts file
	before writing graph header.
	(coverage_finish): Don't unlink the data file if we can generate a
	unique file stamp.
	* tree.h (crc32_unsigned): Declare.
	* tree.c (crc32_unsigned_bits): New, broken out of ...
	(crc32_byte): ... here.  Use it.
	(crc32_unsigned): New.

From-SVN: r189095
parent 1ec205bf
2012-06-30 Nathan Sidwell <nathan@acm.org>
* coverage.c (bbg_file_stamp): New.
(read_counts_file): Merge incoming stamp with bbg_file_stamp.
(build_info): Write bbg_file_stamp.
(coverage_init): Initialize bbg_file_stamp. Read counts file
before writing graph header.
(coverage_finish): Don't unlink the data file if we can generate a
unique file stamp.
* tree.h (crc32_unsigned): Declare.
* tree.c (crc32_unsigned_bits): New, broken out of ...
(crc32_byte): ... here. Use it.
(crc32_unsigned): New.
2012-06-29 Cary Coutant <ccoutant@google.com> 2012-06-29 Cary Coutant <ccoutant@google.com>
* dwarf2out.c (add_pubname_string): Don't check for want_pubnames. * dwarf2out.c (add_pubname_string): Don't check for want_pubnames.
......
...@@ -101,6 +101,9 @@ static GTY(()) tree gcov_fn_info_ptr_type; ...@@ -101,6 +101,9 @@ static GTY(()) tree gcov_fn_info_ptr_type;
we're not writing to the notes file. */ we're not writing to the notes file. */
static char *bbg_file_name; static char *bbg_file_name;
/* File stamp for graph file. */
static unsigned bbg_file_stamp;
/* Name of the count data file. */ /* Name of the count data file. */
static char *da_file_name; static char *da_file_name;
...@@ -205,8 +208,9 @@ read_counts_file (void) ...@@ -205,8 +208,9 @@ read_counts_file (void)
return; return;
} }
/* Read and discard the stamp. */ /* Read the stamp, used for creating a generation count. */
gcov_read_unsigned (); tag = gcov_read_unsigned ();
bbg_file_stamp = crc32_unsigned (bbg_file_stamp, tag);
counts_hash = htab_create (10, counts_hash = htab_create (10,
htab_counts_entry_hash, htab_counts_entry_eq, htab_counts_entry_hash, htab_counts_entry_eq,
...@@ -905,7 +909,7 @@ build_info (tree info_type, tree fn_ary) ...@@ -905,7 +909,7 @@ build_info (tree info_type, tree fn_ary)
/* stamp */ /* stamp */
CONSTRUCTOR_APPEND_ELT (v1, info_fields, CONSTRUCTOR_APPEND_ELT (v1, info_fields,
build_int_cstu (TREE_TYPE (info_fields), build_int_cstu (TREE_TYPE (info_fields),
local_tick)); bbg_file_stamp));
info_fields = DECL_CHAIN (info_fields); info_fields = DECL_CHAIN (info_fields);
/* Filename */ /* Filename */
...@@ -1101,6 +1105,11 @@ coverage_init (const char *filename) ...@@ -1101,6 +1105,11 @@ coverage_init (const char *filename)
memcpy (da_file_name + prefix_len, filename, len); memcpy (da_file_name + prefix_len, filename, len);
strcpy (da_file_name + prefix_len + len, GCOV_DATA_SUFFIX); strcpy (da_file_name + prefix_len + len, GCOV_DATA_SUFFIX);
bbg_file_stamp = local_tick;
if (flag_branch_probabilities)
read_counts_file ();
/* Name of bbg file. */ /* Name of bbg file. */
if (flag_test_coverage && !flag_compare_debug) if (flag_test_coverage && !flag_compare_debug)
{ {
...@@ -1117,12 +1126,9 @@ coverage_init (const char *filename) ...@@ -1117,12 +1126,9 @@ coverage_init (const char *filename)
{ {
gcov_write_unsigned (GCOV_NOTE_MAGIC); gcov_write_unsigned (GCOV_NOTE_MAGIC);
gcov_write_unsigned (GCOV_VERSION); gcov_write_unsigned (GCOV_VERSION);
gcov_write_unsigned (local_tick); gcov_write_unsigned (bbg_file_stamp);
} }
} }
if (flag_branch_probabilities)
read_counts_file ();
} }
/* Performs file-level cleanup. Close graph file, generate coverage /* Performs file-level cleanup. Close graph file, generate coverage
...@@ -1133,10 +1139,11 @@ coverage_finish (void) ...@@ -1133,10 +1139,11 @@ coverage_finish (void)
{ {
if (bbg_file_name && gcov_close ()) if (bbg_file_name && gcov_close ())
unlink (bbg_file_name); unlink (bbg_file_name);
if (!local_tick || local_tick == (unsigned)-1) if (!flag_branch_probabilities && flag_test_coverage
/* Only remove the da file, if we cannot stamp it. If we can && (!local_tick || local_tick == (unsigned)-1))
stamp it, libgcov will DTRT. */ /* Only remove the da file, if we're emitting coverage code and
cannot uniquely stamp it. If we can stamp it, libgcov will DTRT. */
unlink (da_file_name); unlink (da_file_name);
if (coverage_obj_init ()) if (coverage_obj_init ())
......
...@@ -8738,23 +8738,37 @@ dump_tree_statistics (void) ...@@ -8738,23 +8738,37 @@ dump_tree_statistics (void)
/* Generate a crc32 of a byte. */ /* Generate a crc32 of a byte. */
unsigned static unsigned
crc32_byte (unsigned chksum, char byte) crc32_unsigned_bits (unsigned chksum, unsigned value, unsigned bits)
{ {
unsigned value = (unsigned) byte << 24; unsigned ix;
unsigned ix;
for (ix = 8; ix--; value <<= 1)
{
unsigned feedback;
feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0; for (ix = bits; ix--; value <<= 1)
chksum <<= 1; {
chksum ^= feedback; unsigned feedback;
}
feedback = (value ^ chksum) & 0x80000000 ? 0x04c11db7 : 0;
chksum <<= 1;
chksum ^= feedback;
}
return chksum; return chksum;
} }
/* Generate a crc32 of a 32-bit unsigned. */
unsigned
crc32_unsigned (unsigned chksum, unsigned value)
{
return crc32_unsigned_bits (chksum, value, 32);
}
/* Generate a crc32 of a byte. */
unsigned
crc32_byte (unsigned chksum, char byte)
{
return crc32_unsigned_bits (chksum, (unsigned) byte << 24, 8);
}
/* Generate a crc32 of a string. */ /* Generate a crc32 of a string. */
......
...@@ -5170,6 +5170,7 @@ inlined_function_outer_scope_p (const_tree block) ...@@ -5170,6 +5170,7 @@ inlined_function_outer_scope_p (const_tree block)
/* In tree.c */ /* In tree.c */
extern unsigned crc32_string (unsigned, const char *); extern unsigned crc32_string (unsigned, const char *);
extern unsigned crc32_byte (unsigned, char); extern unsigned crc32_byte (unsigned, char);
extern unsigned crc32_unsigned (unsigned, unsigned);
extern void clean_symbol_name (char *); extern void clean_symbol_name (char *);
extern tree get_file_function_name (const char *); extern tree get_file_function_name (const char *);
extern tree get_callee_fndecl (const_tree); extern tree get_callee_fndecl (const_tree);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment