defaults.h (GCOV_TYPE_SIZE): Remove.

* defaults.h (GCOV_TYPE_SIZE): Remove.
	* gcov-io.h (gcov_type): Set to specific mode int on target.
	(gcov_unsigned_t, gcov_position_t): New.
	(GCOV_TYPE_NODE): New.
	(GCOV_TAG_SUMMARY_LENGTH): Adjust.
	(GCOV_COUNTERS_SUMMABLE): New.
	(gcov_ctr_summary, gcov_sumary, gcov_fn_info, gcov_merge_fn,
	gcov_ctr_info, gcov_info): Adjust types.
	(gcov_var): Adjust types.
	(gcov_write_unsigned, gcov_write_tag,
	gcov_write_length, gcov_write_tag_length, gcov_write_summary,
	gcov_read_unsigned, gcov_read_summary): Adjust gcov types.
	(gcov_position, gcov_sync, gcov_seek): Adjust gcov types.
	* gcov-io.c (gcov_write_unsigned, gcov_write_tag,
	gcov_write_length, gcov_write_tag_length, gcov_write_summary,
	gcov_read_unsigned, gcov_read_summary): Adjust gcov types.
	* libgcov.c (gcov_crc32, gcov_version_mismatch, gcov_exit,
	__gcov_init, __gcov_merge_add): Adjust gcov types.
	* coverage.c (ctr_merge_functions): Constify.
	(ctr_names): New.
	(read_counts_file): Adjust gcov types. Only summarize & merge
	summable counters.
	(coverage_counter_ref): Use GCOV_TYPE_NODE.
	(build_fn_info_type, build_fn_info_value, build_ctr_info_type,
	build_ctr_info_value, build_gcov_info): Adjust types.
	* profile.c (branch_prob): Adjust gcov types.
	* gcov_dump (dump_file): Adjust gcov types.

From-SVN: r66668
This commit is contained in:
Nathan Sidwell 2003-05-10 19:02:21 +00:00 committed by Nathan Sidwell
parent bac45eb9ff
commit 9b514d2586
8 changed files with 177 additions and 129 deletions

View File

@ -1,3 +1,33 @@
2003-05-10 Nathan Sidwell <nathan@codesourcery.com>
* defaults.h (GCOV_TYPE_SIZE): Remove.
* gcov-io.h (gcov_type): Set to specific mode int on target.
(gcov_unsigned_t, gcov_position_t): New.
(GCOV_TYPE_NODE): New.
(GCOV_TAG_SUMMARY_LENGTH): Adjust.
(GCOV_COUNTERS_SUMMABLE): New.
(gcov_ctr_summary, gcov_sumary, gcov_fn_info, gcov_merge_fn,
gcov_ctr_info, gcov_info): Adjust types.
(gcov_var): Adjust types.
(gcov_write_unsigned, gcov_write_tag,
gcov_write_length, gcov_write_tag_length, gcov_write_summary,
gcov_read_unsigned, gcov_read_summary): Adjust gcov types.
(gcov_position, gcov_sync, gcov_seek): Adjust gcov types.
* gcov-io.c (gcov_write_unsigned, gcov_write_tag,
gcov_write_length, gcov_write_tag_length, gcov_write_summary,
gcov_read_unsigned, gcov_read_summary): Adjust gcov types.
* libgcov.c (gcov_crc32, gcov_version_mismatch, gcov_exit,
__gcov_init, __gcov_merge_add): Adjust gcov types.
* coverage.c (ctr_merge_functions): Constify.
(ctr_names): New.
(read_counts_file): Adjust gcov types. Only summarize & merge
summable counters.
(coverage_counter_ref): Use GCOV_TYPE_NODE.
(build_fn_info_type, build_fn_info_value, build_ctr_info_type,
build_ctr_info_value, build_gcov_info): Adjust types.
* profile.c (branch_prob): Adjust gcov types.
* gcov_dump (dump_file): Adjust gcov types.
2003-05-10 Richard Earnshaw <rearnsha@arm.com> 2003-05-10 Richard Earnshaw <rearnsha@arm.com>
* arm.md (DOM_CC_X_AND_Y, DOM_CC_NX_OR_Y, DOM_CC_X_OR_Y): New * arm.md (DOM_CC_X_AND_Y, DOM_CC_NX_OR_Y, DOM_CC_X_OR_Y): New

View File

@ -99,7 +99,8 @@ static htab_t counts_hash = NULL;
static GTY(()) rtx ctr_labels[GCOV_COUNTERS]; static GTY(()) rtx ctr_labels[GCOV_COUNTERS];
/* The names of merge functions for counters. */ /* The names of merge functions for counters. */
static const char *ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS; static const char *const ctr_merge_functions[GCOV_COUNTERS] = GCOV_MERGE_FUNCTIONS;
static const char *const ctr_names[GCOV_COUNTERS] = GCOV_COUNTER_NAMES;
/* Forward declarations. */ /* Forward declarations. */
static hashval_t htab_counts_entry_hash PARAMS ((const void *)); static hashval_t htab_counts_entry_hash PARAMS ((const void *));
@ -151,8 +152,9 @@ htab_counts_entry_del (of)
static void static void
read_counts_file () read_counts_file ()
{ {
unsigned fn_ident = 0; gcov_unsigned_t fn_ident = 0;
unsigned version, ix, checksum = -1; gcov_unsigned_t version, checksum = -1;
unsigned ix;
counts_entry_t *summaried = NULL; counts_entry_t *summaried = NULL;
unsigned seen_summary = 0; unsigned seen_summary = 0;
@ -168,7 +170,7 @@ read_counts_file ()
else if ((version = gcov_read_unsigned ()) != GCOV_VERSION) else if ((version = gcov_read_unsigned ()) != GCOV_VERSION)
{ {
char v[4], e[4]; char v[4], e[4];
unsigned required = GCOV_VERSION; gcov_unsigned_t required = GCOV_VERSION;
for (ix = 4; ix--; required >>= 8, version >>= 8) for (ix = 4; ix--; required >>= 8, version >>= 8)
{ {
@ -186,8 +188,8 @@ read_counts_file ()
htab_counts_entry_del); htab_counts_entry_del);
while (!gcov_is_eof ()) while (!gcov_is_eof ())
{ {
unsigned tag, length; gcov_unsigned_t tag, length;
unsigned long offset; gcov_position_t offset;
int error; int error;
tag = gcov_read_unsigned (); tag = gcov_read_unsigned ();
@ -259,17 +261,25 @@ read_counts_file ()
htab_delete (counts_hash); htab_delete (counts_hash);
break; break;
} }
else if (elt.ctr >= GCOV_COUNTERS_SUMMABLE)
/* This should always be true for a just allocated entry, {
and always false for an existing one. Check this way, in warning ("cannot merge separate %s counters for function %u",
case the gcov file is corrupt. */ ctr_names[elt.ctr], fn_ident);
if (!entry->chain || summaried != entry) goto skip_merge;
}
if (elt.ctr < GCOV_COUNTERS_SUMMABLE
/* This should always be true for a just allocated entry,
and always false for an existing one. Check this way, in
case the gcov file is corrupt. */
&& (!entry->chain || summaried != entry))
{ {
entry->chain = summaried; entry->chain = summaried;
summaried = entry; summaried = entry;
} }
for (ix = 0; ix != n_counts; ix++) for (ix = 0; ix != n_counts; ix++)
entry->counts[ix] += gcov_read_counter (); entry->counts[ix] += gcov_read_counter ();
skip_merge:;
} }
gcov_sync (offset, length); gcov_sync (offset, length);
if ((error = gcov_is_error ())) if ((error = gcov_is_error ()))
@ -332,7 +342,8 @@ get_coverage_counts (unsigned counter, unsigned expected,
rtx rtx
coverage_counter_ref (unsigned counter, unsigned no) coverage_counter_ref (unsigned counter, unsigned no)
{ {
enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0); unsigned gcov_size = tree_low_cst (TYPE_SIZE (GCOV_TYPE_NODE), 1);
enum machine_mode mode = mode_for_size (gcov_size, MODE_INT, 0);
rtx ref; rtx ref;
if (!ctr_labels[counter]) if (!ctr_labels[counter])
@ -350,8 +361,7 @@ coverage_counter_ref (unsigned counter, unsigned no)
} }
no += prg_n_ctrs[counter]; no += prg_n_ctrs[counter];
ref = plus_constant (ctr_labels[counter], ref = plus_constant (ctr_labels[counter], gcov_size / BITS_PER_UNIT * no);
GCOV_TYPE_SIZE / BITS_PER_UNIT * no);
ref = gen_rtx_MEM (mode, ref); ref = gen_rtx_MEM (mode, ref);
set_mem_alias_set (ref, new_alias_set ()); set_mem_alias_set (ref, new_alias_set ());
@ -489,10 +499,10 @@ build_fn_info_type (counters)
tree array_type; tree array_type;
/* ident */ /* ident */
fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node); fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
/* checksum */ /* checksum */
field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node); field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
fields = field; fields = field;
@ -525,14 +535,14 @@ build_fn_info_value (function, type)
/* ident */ /* ident */
value = tree_cons (fields, value = tree_cons (fields,
convert (unsigned_type_node, convert (unsigned_intSI_type_node,
build_int_2 (function->ident, 0)), build_int_2 (function->ident, 0)),
value); value);
fields = TREE_CHAIN (fields); fields = TREE_CHAIN (fields);
/* checksum */ /* checksum */
value = tree_cons (fields, value = tree_cons (fields,
convert (unsigned_type_node, convert (unsigned_intSI_type_node,
build_int_2 (function->checksum, 0)), build_int_2 (function->checksum, 0)),
value); value);
fields = TREE_CHAIN (fields); fields = TREE_CHAIN (fields);
@ -562,26 +572,24 @@ build_ctr_info_type ()
{ {
tree type = (*lang_hooks.types.make_type) (RECORD_TYPE); tree type = (*lang_hooks.types.make_type) (RECORD_TYPE);
tree field, fields = NULL_TREE; tree field, fields = NULL_TREE;
tree gcov_ptr_type = build_pointer_type (GCOV_TYPE_NODE);
tree gcov_merge_fn_type; tree gcov_merge_fn_type;
/* counters */ /* counters */
field = build_decl (FIELD_DECL, NULL_TREE, unsigned_type_node); field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
fields = field; fields = field;
/* values */ /* values */
field = build_decl (FIELD_DECL, NULL_TREE, field = build_decl (FIELD_DECL, NULL_TREE, gcov_ptr_type);
build_pointer_type (make_signed_type (GCOV_TYPE_SIZE)));
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
fields = field; fields = field;
/* merge */ /* merge */
gcov_merge_fn_type = gcov_merge_fn_type =
build_function_type_list ( build_function_type_list (void_type_node,
void_type_node, gcov_ptr_type, unsigned_type_node,
build_pointer_type (make_signed_type (GCOV_TYPE_SIZE)), NULL_TREE);
unsigned_type_node,
NULL_TREE);
field = build_decl (FIELD_DECL, NULL_TREE, field = build_decl (FIELD_DECL, NULL_TREE,
build_pointer_type (gcov_merge_fn_type)); build_pointer_type (gcov_merge_fn_type));
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
@ -607,7 +615,7 @@ build_ctr_info_value (counter, type)
/* counters */ /* counters */
value = tree_cons (fields, value = tree_cons (fields,
convert (unsigned_type_node, convert (unsigned_intSI_type_node,
build_int_2 (prg_n_ctrs[counter], 0)), build_int_2 (prg_n_ctrs[counter], 0)),
value); value);
fields = TREE_CHAIN (fields); fields = TREE_CHAIN (fields);
@ -641,9 +649,7 @@ build_ctr_info_value (counter, type)
DECL_ARTIFICIAL (fn) = 1; DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1; TREE_NOTHROW (fn) = 1;
value = tree_cons (fields, value = tree_cons (fields,
build1 (ADDR_EXPR, build1 (ADDR_EXPR, TREE_TYPE (fields), fn),
TREE_TYPE (fields),
fn),
value); value);
value = build_constructor (type, nreverse (value)); value = build_constructor (type, nreverse (value));
@ -680,10 +686,10 @@ build_gcov_info ()
const_type = build_qualified_type (type, TYPE_QUAL_CONST); const_type = build_qualified_type (type, TYPE_QUAL_CONST);
/* Version ident */ /* Version ident */
field = build_decl (FIELD_DECL, NULL_TREE, long_unsigned_type_node); field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
TREE_CHAIN (field) = fields; TREE_CHAIN (field) = fields;
fields = field; fields = field;
value = tree_cons (field, convert (long_unsigned_type_node, value = tree_cons (field, convert (unsigned_intSI_type_node,
build_int_2 (GCOV_VERSION, 0)), build_int_2 (GCOV_VERSION, 0)),
value); value);

View File

@ -404,15 +404,6 @@ do { fputs (integer_asm_op (POINTER_SIZE / UNITS_PER_WORD, TRUE), FILE); \
#define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM #define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
#endif #endif
/* Type used by GCOV counters. Use 64bit data type if target supports
it. */
#if LONG_TYPE_SIZE >= 64
#define GCOV_TYPE_SIZE LONG_TYPE_SIZE
#else
#define GCOV_TYPE_SIZE LONG_LONG_TYPE_SIZE
#endif
/* By default, the preprocessor should be invoked the same way in C++ /* By default, the preprocessor should be invoked the same way in C++
as in C. */ as in C. */
#ifndef CPLUSPLUS_CPP_SPEC #ifndef CPLUSPLUS_CPP_SPEC

View File

@ -241,7 +241,8 @@ dump_file (filename)
if ((error = gcov_is_error ())) if ((error = gcov_is_error ()))
{ {
printf (error < 0 ? "%s:counter overflow at %lu\n" : printf (error < 0 ? "%s:counter overflow at %lu\n" :
"%s:read error at %lu\n", filename, gcov_position ()); "%s:read error at %lu\n", filename,
(long unsigned) gcov_position ());
break; break;
} }
} }

View File

@ -181,7 +181,7 @@ gcov_write_bytes (unsigned bytes)
appropriately. */ appropriately. */
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_unsigned (unsigned value) gcov_write_unsigned (gcov_unsigned_t value)
{ {
unsigned char *buffer = gcov_write_bytes (4); unsigned char *buffer = gcov_write_bytes (4);
unsigned ix; unsigned ix;
@ -261,10 +261,10 @@ gcov_write_string (const char *string)
/* Write a tag TAG and reserve space for the record length. Return a /* Write a tag TAG and reserve space for the record length. Return a
value to be used for gcov_write_length. */ value to be used for gcov_write_length. */
GCOV_LINKAGE unsigned long GCOV_LINKAGE gcov_position_t
gcov_write_tag (unsigned tag) gcov_write_tag (gcov_unsigned_t tag)
{ {
unsigned long result = gcov_var.position; gcov_position_t result = gcov_var.position;
unsigned char *buffer = gcov_write_bytes (8); unsigned char *buffer = gcov_write_bytes (8);
unsigned ix; unsigned ix;
@ -285,11 +285,11 @@ gcov_write_tag (unsigned tag)
overflow. */ overflow. */
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_length (unsigned long position) gcov_write_length (gcov_position_t position)
{ {
if (position) if (position)
{ {
unsigned length = gcov_var.position - position - 8; gcov_unsigned_t length = gcov_var.position - position - 8;
unsigned char *buffer = &gcov_var.buffer[position + 4]; unsigned char *buffer = &gcov_var.buffer[position + 4];
unsigned ix; unsigned ix;
@ -300,12 +300,13 @@ gcov_write_length (unsigned long position)
} }
} }
} }
#endif
#else /* IN_LIBGCOV */
/* Write a tag TAG and length LENGTH. */ /* Write a tag TAG and length LENGTH. */
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_tag_length (unsigned tag, unsigned length) gcov_write_tag_length (gcov_unsigned_t tag, gcov_unsigned_t length)
{ {
unsigned char *buffer = gcov_write_bytes (8); unsigned char *buffer = gcov_write_bytes (8);
unsigned ix; unsigned ix;
@ -325,19 +326,18 @@ gcov_write_tag_length (unsigned tag, unsigned length)
return; return;
} }
#if IN_LIBGCOV
/* Write a summary structure to the gcov file. Return non-zero on /* Write a summary structure to the gcov file. Return non-zero on
overflow. */ overflow. */
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_summary (unsigned tag, const struct gcov_summary *summary) gcov_write_summary (gcov_unsigned_t tag, const struct gcov_summary *summary)
{ {
unsigned ix; unsigned ix;
const struct gcov_ctr_summary *csum; const struct gcov_ctr_summary *csum;
gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH); gcov_write_tag_length (tag, GCOV_TAG_SUMMARY_LENGTH);
gcov_write_unsigned (summary->checksum); gcov_write_unsigned (summary->checksum);
for (csum = summary->ctrs, ix = GCOV_COUNTERS; ix--; csum++) for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
{ {
gcov_write_unsigned (csum->num); gcov_write_unsigned (csum->num);
gcov_write_unsigned (csum->runs); gcov_write_unsigned (csum->runs);
@ -372,10 +372,10 @@ gcov_read_bytes (unsigned bytes)
/* Read unsigned value from a coverage file. Sets error flag on file /* Read unsigned value from a coverage file. Sets error flag on file
error, overflow flag on overflow */ error, overflow flag on overflow */
GCOV_LINKAGE unsigned GCOV_LINKAGE gcov_unsigned_t
gcov_read_unsigned () gcov_read_unsigned ()
{ {
unsigned value = 0; gcov_unsigned_t value = 0;
unsigned ix; unsigned ix;
const unsigned char *buffer = gcov_read_bytes (4); const unsigned char *buffer = gcov_read_bytes (4);
@ -442,7 +442,7 @@ gcov_read_summary (struct gcov_summary *summary)
struct gcov_ctr_summary *csum; struct gcov_ctr_summary *csum;
summary->checksum = gcov_read_unsigned (); summary->checksum = gcov_read_unsigned ();
for (csum = summary->ctrs, ix = GCOV_COUNTERS; ix--; csum++) for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
{ {
csum->num = gcov_read_unsigned (); csum->num = gcov_read_unsigned ();
csum->runs = gcov_read_unsigned (); csum->runs = gcov_read_unsigned ();

View File

@ -158,29 +158,48 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define GCC_GCOV_IO_H #define GCC_GCOV_IO_H
#if IN_LIBGCOV #if IN_LIBGCOV
#if LONG_TYPE_SIZE == GCOV_TYPE_SIZE /* About the target */
typedef long gcov_type;
typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI)));
typedef unsigned gcov_position_t __attribute__ ((mode (SI)));
#if LONG_LONG_TYPE_SIZE > 32
typedef signed gcov_type __attribute__ ((mode (DI)));
#else #else
typedef long long gcov_type; typedef signed gcov_type __attribute__ ((mode (SI)));
#endif #endif
#if defined (TARGET_HAS_F_SETLKW) #if defined (TARGET_HAS_F_SETLKW)
#define GCOV_LOCKED 1 #define GCOV_LOCKED 1
#else #else
#define GCOV_LOCKED 0 #define GCOV_LOCKED 0
#endif #endif
#else /* !IN_LIBGCOV */ #else /* !IN_LIBGCOV */
#if defined (HOST_HAS_F_SETLKW) /* About the host */
#define GCOV_LOCKED 1
#else typedef unsigned gcov_unsigned_t;
#define GCOV_LOCKED 0 typedef unsigned gcov_position_t;
#endif /* gcov_type is typedef'd elsewhere for the compiler */
#if IN_GCOV #if IN_GCOV
#define GCOV_LINKAGE static #define GCOV_LINKAGE static
typedef HOST_WIDEST_INT gcov_type; typedef HOST_WIDEST_INT gcov_type;
#if IN_GCOV > 0 #if IN_GCOV > 0
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#else /*!IN_GCOV */
#if LONG_LONG_TYPE_SIZE > 32
#define GCOV_TYPE_NODE intDI_type_node
#else
#define GCOV_TYPE_NODE intSI_type_node
#endif #endif
#endif
#if defined (HOST_HAS_F_SETLKW)
#define GCOV_LOCKED 1
#else
#define GCOV_LOCKED 0
#endif
#endif /* !IN_LIBGCOV */ #endif /* !IN_LIBGCOV */
/* In gcov we want function linkage to be static, so we do not /* In gcov we want function linkage to be static, so we do not
@ -247,10 +266,12 @@ typedef HOST_WIDEST_INT gcov_type;
#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 8) #define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 8)
#define GCOV_TAG_OBJECT_SUMMARY ((unsigned)0xa1000000) #define GCOV_TAG_OBJECT_SUMMARY ((unsigned)0xa1000000)
#define GCOV_TAG_PROGRAM_SUMMARY ((unsigned)0xa3000000) #define GCOV_TAG_PROGRAM_SUMMARY ((unsigned)0xa3000000)
#define GCOV_TAG_SUMMARY_LENGTH (1 * 4 + GCOV_COUNTERS * (2 * 4 + 3 * 8)) #define GCOV_TAG_SUMMARY_LENGTH (1 * 4 + GCOV_COUNTERS_SUMMABLE * (2 * 4 + 3 * 8))
/* Counters that are collected. */ /* Counters that are collected. */
#define GCOV_COUNTER_ARCS 0 /* Arc transitions. */ #define GCOV_COUNTER_ARCS 0 /* Arc transitions. */
#define GCOV_COUNTERS_SUMMABLE 1 /* Counters which can be
summaried. */
#define GCOV_COUNTERS 1 #define GCOV_COUNTERS 1
/* A list of human readable names of the counters */ /* A list of human readable names of the counters */
@ -296,18 +317,18 @@ typedef HOST_WIDEST_INT gcov_type;
/* Cumulative counter data. */ /* Cumulative counter data. */
struct gcov_ctr_summary struct gcov_ctr_summary
{ {
unsigned num; /* number of counters. */ gcov_unsigned_t num; /* number of counters. */
unsigned runs; /* number of program runs */ gcov_unsigned_t runs; /* number of program runs */
gcov_type sum_all; /* sum of all counters accumulated. */ gcov_type sum_all; /* sum of all counters accumulated. */
gcov_type run_max; /* maximum value on a single run. */ gcov_type run_max; /* maximum value on a single run. */
gcov_type sum_max; /* sum of individual run max values. */ gcov_type sum_max; /* sum of individual run max values. */
}; };
/* Object & program summary record. */ /* Object & program summary record. */
struct gcov_summary struct gcov_summary
{ {
unsigned checksum; /* checksum of program */ gcov_unsigned_t checksum; /* checksum of program */
struct gcov_ctr_summary ctrs[GCOV_COUNTERS]; struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
}; };
/* Structures embedded in coveraged program. The structures generated /* Structures embedded in coveraged program. The structures generated
@ -320,34 +341,34 @@ struct gcov_summary
explicitly calculate the correct array stride. */ explicitly calculate the correct array stride. */
struct gcov_fn_info struct gcov_fn_info
{ {
unsigned ident; /* unique ident of function */ gcov_unsigned_t ident; /* unique ident of function */
unsigned checksum; /* function checksum */ gcov_unsigned_t checksum; /* function checksum */
unsigned n_ctrs[0]; /* instrumented counters */ unsigned n_ctrs[0]; /* instrumented counters */
}; };
/* Type of function used to merge counters. */ /* Type of function used to merge counters. */
typedef void (*gcov_merge_fn) (gcov_type *, unsigned); typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t);
/* Information about counters. */ /* Information about counters. */
struct gcov_ctr_info struct gcov_ctr_info
{ {
unsigned num; /* number of counters. */ gcov_unsigned_t num; /* number of counters. */
gcov_type *values; /* their values. */ gcov_type *values; /* their values. */
gcov_merge_fn merge; /* The function used to merge them. */ gcov_merge_fn merge; /* The function used to merge them. */
}; };
/* Information about a single object file. */ /* Information about a single object file. */
struct gcov_info struct gcov_info
{ {
unsigned long version; /* expected version number */ gcov_unsigned_t version; /* expected version number */
struct gcov_info *next; /* link to next, used by libgcc */ struct gcov_info *next; /* link to next, used by libgcc */
const char *filename; /* output file name */ const char *filename; /* output file name */
unsigned n_functions; /* number of functions */ unsigned n_functions; /* number of functions */
const struct gcov_fn_info *functions; /* table of functions */ const struct gcov_fn_info *functions; /* table of functions */
unsigned ctr_mask; /* mask of counters instrumented. */ unsigned ctr_mask; /* mask of counters instrumented. */
struct gcov_ctr_info counts[0]; /* count data. The number of bits struct gcov_ctr_info counts[0]; /* count data. The number of bits
set in the ctr_mask field set in the ctr_mask field
determines how big this array determines how big this array
@ -372,8 +393,8 @@ extern void __gcov_merge_add (gcov_type *, unsigned);
GCOV_LINKAGE struct gcov_var GCOV_LINKAGE struct gcov_var
{ {
FILE *file; FILE *file;
size_t position; gcov_position_t position;
size_t length; gcov_position_t length;
size_t alloc; size_t alloc;
unsigned modified; unsigned modified;
int error; int error;
@ -385,31 +406,31 @@ GCOV_LINKAGE int gcov_open (const char */*name*/, int /*truncate*/);
GCOV_LINKAGE int gcov_close (void); GCOV_LINKAGE int gcov_close (void);
#if !IN_GCOV #if !IN_GCOV
GCOV_LINKAGE unsigned char *gcov_write_bytes (unsigned); GCOV_LINKAGE unsigned char *gcov_write_bytes (unsigned);
GCOV_LINKAGE void gcov_write_unsigned (unsigned); GCOV_LINKAGE void gcov_write_unsigned (gcov_unsigned_t);
#if IN_LIBGCOV #if IN_LIBGCOV
GCOV_LINKAGE void gcov_write_counter (gcov_type); GCOV_LINKAGE void gcov_write_counter (gcov_type);
#else #else
GCOV_LINKAGE void gcov_write_string (const char *); GCOV_LINKAGE void gcov_write_string (const char *);
#endif #endif
#if !IN_LIBGCOV #if !IN_LIBGCOV
GCOV_LINKAGE unsigned long gcov_write_tag (unsigned); GCOV_LINKAGE gcov_position_t gcov_write_tag (gcov_unsigned_t);
GCOV_LINKAGE void gcov_write_length (unsigned long /*position*/); GCOV_LINKAGE void gcov_write_length (gcov_position_t /*position*/);
#endif #else
GCOV_LINKAGE void gcov_write_tag_length (unsigned, unsigned); GCOV_LINKAGE void gcov_write_tag_length (gcov_unsigned_t, gcov_unsigned_t);
#if IN_LIBGCOV GCOV_LINKAGE void gcov_write_summary (gcov_unsigned_t /*tag*/,
GCOV_LINKAGE void gcov_write_summary (unsigned, const struct gcov_summary *); const struct gcov_summary *);
#endif #endif
#endif /* !IN_GCOV */ #endif /* !IN_GCOV */
GCOV_LINKAGE const unsigned char *gcov_read_bytes (unsigned); GCOV_LINKAGE const unsigned char *gcov_read_bytes (unsigned);
GCOV_LINKAGE unsigned gcov_read_unsigned (void); GCOV_LINKAGE gcov_unsigned_t gcov_read_unsigned (void);
GCOV_LINKAGE gcov_type gcov_read_counter (void); GCOV_LINKAGE gcov_type gcov_read_counter (void);
#if !IN_LIBGCOV #if !IN_LIBGCOV
GCOV_LINKAGE const char *gcov_read_string (void); GCOV_LINKAGE const char *gcov_read_string (void);
#endif #endif
GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *); GCOV_LINKAGE void gcov_read_summary (struct gcov_summary *);
static unsigned long gcov_position (void); static gcov_position_t gcov_position (void);
static void gcov_sync (unsigned long /*base*/, unsigned /*length */); static void gcov_sync (gcov_position_t /*base*/, gcov_unsigned_t /*length */);
static void gcov_seek (unsigned long /*position*/); static void gcov_seek (gcov_position_t /*position*/);
static void gcov_rewrite (void); static void gcov_rewrite (void);
static int gcov_is_eof (void); static int gcov_is_eof (void);
static int gcov_is_error (void); static int gcov_is_error (void);
@ -419,7 +440,7 @@ GCOV_LINKAGE time_t gcov_time (void);
/* Save the current position in the gcov file. */ /* Save the current position in the gcov file. */
static inline unsigned long static inline gcov_position_t
gcov_position (void) gcov_position (void)
{ {
return gcov_var.position; return gcov_var.position;
@ -429,7 +450,7 @@ gcov_position (void)
gcov_save_position, LENGTH should be a record length, or zero. */ gcov_save_position, LENGTH should be a record length, or zero. */
static inline void static inline void
gcov_sync (unsigned long base, unsigned length) gcov_sync (gcov_position_t base, gcov_unsigned_t length)
{ {
if (gcov_var.buffer) if (gcov_var.buffer)
{ {
@ -446,7 +467,7 @@ gcov_sync (unsigned long base, unsigned length)
/* Move to the end of the gcov file. */ /* Move to the end of the gcov file. */
static inline void static inline void
gcov_seek (unsigned long base) gcov_seek (gcov_position_t base)
{ {
gcov_var.position = base < gcov_var.length ? base : gcov_var.length; gcov_var.position = base < gcov_var.length ? base : gcov_var.length;
} }

View File

@ -79,12 +79,12 @@ static struct gcov_info *gcov_list;
/* A program checksum allows us to distinguish program data for an /* A program checksum allows us to distinguish program data for an
object file included in multiple programs. */ object file included in multiple programs. */
static unsigned gcov_crc32; static gcov_unsigned_t gcov_crc32;
static void static void
gcov_version_mismatch (struct gcov_info *ptr, unsigned version) gcov_version_mismatch (struct gcov_info *ptr, gcov_unsigned_t version)
{ {
unsigned expected = GCOV_VERSION; gcov_unsigned_t expected = GCOV_VERSION;
unsigned ix; unsigned ix;
char e[4], v[4]; char e[4], v[4];
@ -123,11 +123,11 @@ gcov_exit (void)
unsigned t_ix; unsigned t_ix;
for (t_ix = 0, ci_ptr = gi_ptr->counts, cs_ptr = this_program.ctrs; for (t_ix = 0, ci_ptr = gi_ptr->counts, cs_ptr = this_program.ctrs;
t_ix != GCOV_COUNTERS; t_ix++, cs_ptr++) t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++, cs_ptr++)
if ((1 << t_ix) & gi_ptr->ctr_mask) if ((1 << t_ix) & gi_ptr->ctr_mask)
{ {
const gcov_type *c_ptr; const gcov_type *c_ptr;
unsigned c_num; gcov_unsigned_t c_num;
cs_ptr->num += ci_ptr->num; cs_ptr->num += ci_ptr->num;
for (c_num = ci_ptr->num, c_ptr = ci_ptr->values; c_num--; c_ptr++) for (c_num = ci_ptr->num, c_ptr = ci_ptr->values; c_num--; c_ptr++)
@ -140,7 +140,7 @@ gcov_exit (void)
} }
} }
/* Now write the data */ /* Now merge each file */
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
{ {
struct gcov_summary this_object; struct gcov_summary this_object;
@ -154,18 +154,18 @@ gcov_exit (void)
struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all; struct gcov_ctr_summary *cs_obj, *cs_tobj, *cs_prg, *cs_tprg, *cs_all;
int error; int error;
int merging; int merging;
unsigned tag, length; gcov_unsigned_t tag, length;
unsigned long summary_pos = ~0UL; gcov_position_t summary_pos = ~(gcov_position_t)0;
/* Totals for this object file. */ /* Totals for this object file. */
memset (&this_object, 0, sizeof (this_object)); memset (&this_object, 0, sizeof (this_object));
for (t_ix = c_ix = 0, for (t_ix = c_ix = 0,
ci_ptr = gi_ptr->counts, cs_ptr = this_object.ctrs; ci_ptr = gi_ptr->counts, cs_ptr = this_object.ctrs;
t_ix != GCOV_COUNTERS; t_ix++, cs_ptr++) t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++, cs_ptr++)
if ((1 << t_ix) & gi_ptr->ctr_mask) if ((1 << t_ix) & gi_ptr->ctr_mask)
{ {
const gcov_type *c_ptr; const gcov_type *c_ptr;
unsigned c_num; gcov_unsigned_t c_num;
cs_ptr->num += ci_ptr->num; cs_ptr->num += ci_ptr->num;
values[c_ix] = ci_ptr->values; values[c_ix] = ci_ptr->values;
@ -258,7 +258,7 @@ gcov_exit (void)
/* Check program & object summary */ /* Check program & object summary */
while (!gcov_is_eof ()) while (!gcov_is_eof ())
{ {
unsigned long base = gcov_position (); gcov_position_t base = gcov_position ();
int is_program; int is_program;
tag = gcov_read_unsigned (); tag = gcov_read_unsigned ();
@ -295,7 +295,7 @@ gcov_exit (void)
cs_obj = object.ctrs, cs_tobj = this_object.ctrs, cs_obj = object.ctrs, cs_tobj = this_object.ctrs,
cs_prg = program.ctrs, cs_tprg = this_program.ctrs, cs_prg = program.ctrs, cs_tprg = this_program.ctrs,
cs_all = all.ctrs; cs_all = all.ctrs;
t_ix != GCOV_COUNTERS; t_ix != GCOV_COUNTERS_SUMMABLE;
t_ix++, cs_obj++, cs_tobj++, cs_prg++, cs_tprg++, cs_all++) t_ix++, cs_obj++, cs_tobj++, cs_prg++, cs_tprg++, cs_all++)
{ {
if ((1 << t_ix) & gi_ptr->ctr_mask) if ((1 << t_ix) & gi_ptr->ctr_mask)
@ -340,8 +340,7 @@ gcov_exit (void)
program.checksum = gcov_crc32; program.checksum = gcov_crc32;
/* Write out the data. */ /* Write out the data. */
gcov_write_unsigned (GCOV_DATA_MAGIC); gcov_write_tag_length (GCOV_DATA_MAGIC, GCOV_VERSION);
gcov_write_unsigned (GCOV_VERSION);
/* Write execution counts for each function. */ /* Write execution counts for each function. */
for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; f_ix--; for (f_ix = gi_ptr->n_functions, fi_ptr = gi_ptr->functions; f_ix--;
@ -396,16 +395,16 @@ __gcov_init (struct gcov_info *info)
else else
{ {
const char *ptr = info->filename; const char *ptr = info->filename;
unsigned crc32 = gcov_crc32; gcov_unsigned_t crc32 = gcov_crc32;
do do
{ {
unsigned ix; unsigned ix;
unsigned value = *ptr << 24; gcov_unsigned_t value = *ptr << 24;
for (ix = 8; ix--; value <<= 1) for (ix = 8; ix--; value <<= 1)
{ {
unsigned feedback; gcov_unsigned_t feedback;
feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0; feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
crc32 <<= 1; crc32 <<= 1;
@ -456,9 +455,7 @@ __gcov_flush (void)
an array COUNTERS of N_COUNTERS old counters and it reads the same number an array COUNTERS of N_COUNTERS old counters and it reads the same number
of counters from the gcov file. */ of counters from the gcov file. */
void void
__gcov_merge_add (counters, n_counters) __gcov_merge_add (gcov_type *counters, unsigned n_counters)
gcov_type *counters;
unsigned n_counters;
{ {
for (; n_counters; counters++, n_counters--) for (; n_counters; counters++, n_counters--)
*counters += gcov_read_counter (); *counters += gcov_read_counter ();

View File

@ -670,22 +670,25 @@ branch_prob ()
if (rtl_dump_file) if (rtl_dump_file)
fprintf (rtl_dump_file, "%d ignored edges\n", ignored_edges); fprintf (rtl_dump_file, "%d ignored edges\n", ignored_edges);
/* Write the .bbg data from which gcov can reconstruct the basic block /* Write the data from which gcov can reconstruct the basic block
graph. First output the number of basic blocks, and then for every graph. */
edge output the source and target basic block numbers.
NOTE: The format of this file must be compatible with gcov. */
/* Basic block flags */
if (coverage_begin_output ()) if (coverage_begin_output ())
{ {
long offset; gcov_position_t offset;
/* Basic block flags */
offset = gcov_write_tag (GCOV_TAG_BLOCKS); offset = gcov_write_tag (GCOV_TAG_BLOCKS);
for (i = 0; i != (unsigned) (n_basic_blocks + 2); i++) for (i = 0; i != (unsigned) (n_basic_blocks + 2); i++)
gcov_write_unsigned (0); gcov_write_unsigned (0);
gcov_write_length (offset); gcov_write_length (offset);
}
/* Arcs */
/* Arcs */
if (coverage_begin_output ())
{
gcov_position_t offset;
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
{ {
edge e; edge e;
@ -716,12 +719,11 @@ branch_prob ()
} }
} }
/* Output line number information about each basic block for GCOV /* Line numbers. */
utility. */
if (coverage_begin_output ()) if (coverage_begin_output ())
{ {
char const *prev_file_name = NULL; char const *prev_file_name = NULL;
long offset; gcov_position_t offset;
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
{ {