Commit cdb23767 by Nathan Sidwell Committed by Nathan Sidwell

Makefile.in (LIBGCC_DEPS): Add gcov headers.

	* Makefile.in (LIBGCC_DEPS): Add gcov headers.
	(libgcov.a): Depends on LIBGCC_DEPS.
	* basic-block.h (profile_info): Moved here from coverage.h. Made
	a pointer.
	* coverage.c (struct function_list): Fixed array of counter types.
	(struct counts_entry): Keyed by counter type, contains summary.
	(profile_info): Moved to profile.c.
	(prg_ctr_mask, prg_n_ctrs, fn_ctr_mask, fn_n_ctrs): New global
	vars.
	(profiler_label): Remove.
	(ctr_labels): New.
	(set_purpose, label_for_tag, build_counter_section_fields,
	build_counter_section_value, build_counter_section_data_fields,
	build_counter_section_data_values, build_function_info_fields,
	build_function_info_value, gcov_info_fields, gcov_info_value): Remove.
	(build_fn_info_type, build_fn_info_value, build_ctr_info_type,
	build_ctr_info_value, build_gcov_info): New.
	(htab_counts_entry_hash, htab_counts_entry_eq): Adjust.
	(reads_counts_file): Adjust.
	(get_coverage_counts): Takes counter number. Add summary
	parameter. Adjust.
	(coverage_counter_ref): Tkaes counter number. Adjust. Lazily
	create counter array labels.
	(coverage_end_function): Adjust.
	(create_coverage): Adjust.
	(find_counters_section): Remove.
	* coverage.h (MAX_COUNTER_SECTIONS): Remove.
	(struct section_info, struct profile_info): Remove.
	(profile_info): Moved to basic-block.h.
	(coverage_counter_ref): Takes a counter number.
	(get_coverage_counts): Takes a counter number. Added summary
	parameter.
	(find_counters_section): Remove.
	* gcov-dump.c (tag_arc_counts): Rename to ...
	(tag_counters): ... here. Adjust.
	(tag_table): Move tag_counters to 3rd entry. Remove
	PROGRAM_PLACEHOLDER and PROGRAM_INCORRECT entries.
	(dump_file): Check for counter tag values here.
	(tag_summary): Adjust.
	* gcov-io.c (gcov_write_summary, gcov_read_summary): Adjust.
	* gcov-io.h (GCOV_LOCKED): New.
	(GCOV_TAG_ARC_COUNTS): Rename to ...
	(GCOV_TAG_COUNTS_BASE): ... here.
	(GCOV_TAG_PLACEHOLDER_SUMMARY, GCOV_TAG_INCORRECT_SUMMARY):
	Remove.
	(GCOV_COUNTER_ARCS, GCOV_COUNTERS, GCOV_NAMES): New.
	(GCOV_TAG_FOR_COUNTER, GCOV_COUNTER_FOR_TAG,
	GCOV_TAG_IS_COUNTER): New.
	(struct gcov_ctr_summary): New.
	(struct gcov_summary): Adjust.
	(struct gcov_counter_section): Remove.
	struct gcov_counter_section_data): Remove.
	(struct gcov_function_info): Rename to ...
	(struct gcov_fn_info): ... here. Adjust.
	(struct gcov_ctr_info): New.
	(struct gcov_info): Adjust.
	* gcov.c (read_count_file): Adjust.
	(output_lines): Adjust.
	* libgcov.c (gcov_exit): Adjust.
	(__gcov_flush): Adjust.
	* mklibgcc.in (libgcc2_c_dep): Add gcov headers.
	* predict.c (maybe_hot_bb_p, probably_cold_bb_p,
	probably_never_executed_bb_p, compute_frequency_function): Adjust
	profile_info use.
	* profile.c (struct counts_entry): Remove.
	(profile_info): Define here.
	(get_exec_counts): Adjust get_coverage_counts call.
	(compute_branch_probablilities): Remove find_counters_section
	call.
	(gen_edge_profiler): Adjust coverage_counter_ref call.
	* tracer.c (tail_duplicate): Adjust profile_info use.

From-SVN: r65990
parent 2be3b5ce
2003-04-23 Nathan Sidwell <nathan@codesourcery.com>
* Makefile.in (LIBGCC_DEPS): Add gcov headers.
(libgcov.a): Depends on LIBGCC_DEPS.
* basic-block.h (profile_info): Moved here from coverage.h. Made
a pointer.
* coverage.c (struct function_list): Fixed array of counter types.
(struct counts_entry): Keyed by counter type, contains summary.
(profile_info): Moved to profile.c.
(prg_ctr_mask, prg_n_ctrs, fn_ctr_mask, fn_n_ctrs): New global
vars.
(profiler_label): Remove.
(ctr_labels): New.
(set_purpose, label_for_tag, build_counter_section_fields,
build_counter_section_value, build_counter_section_data_fields,
build_counter_section_data_values, build_function_info_fields,
build_function_info_value, gcov_info_fields, gcov_info_value): Remove.
(build_fn_info_type, build_fn_info_value, build_ctr_info_type,
build_ctr_info_value, build_gcov_info): New.
(htab_counts_entry_hash, htab_counts_entry_eq): Adjust.
(reads_counts_file): Adjust.
(get_coverage_counts): Takes counter number. Add summary
parameter. Adjust.
(coverage_counter_ref): Tkaes counter number. Adjust. Lazily
create counter array labels.
(coverage_end_function): Adjust.
(create_coverage): Adjust.
(find_counters_section): Remove.
* coverage.h (MAX_COUNTER_SECTIONS): Remove.
(struct section_info, struct profile_info): Remove.
(profile_info): Moved to basic-block.h.
(coverage_counter_ref): Takes a counter number.
(get_coverage_counts): Takes a counter number. Added summary
parameter.
(find_counters_section): Remove.
* gcov-dump.c (tag_arc_counts): Rename to ...
(tag_counters): ... here. Adjust.
(tag_table): Move tag_counters to 3rd entry. Remove
PROGRAM_PLACEHOLDER and PROGRAM_INCORRECT entries.
(dump_file): Check for counter tag values here.
(tag_summary): Adjust.
* gcov-io.c (gcov_write_summary, gcov_read_summary): Adjust.
* gcov-io.h (GCOV_LOCKED): New.
(GCOV_TAG_ARC_COUNTS): Rename to ...
(GCOV_TAG_COUNTS_BASE): ... here.
(GCOV_TAG_PLACEHOLDER_SUMMARY, GCOV_TAG_INCORRECT_SUMMARY):
Remove.
(GCOV_COUNTER_ARCS, GCOV_COUNTERS, GCOV_NAMES): New.
(GCOV_TAG_FOR_COUNTER, GCOV_COUNTER_FOR_TAG,
GCOV_TAG_IS_COUNTER): New.
(struct gcov_ctr_summary): New.
(struct gcov_summary): Adjust.
(struct gcov_counter_section): Remove.
struct gcov_counter_section_data): Remove.
(struct gcov_function_info): Rename to ...
(struct gcov_fn_info): ... here. Adjust.
(struct gcov_ctr_info): New.
(struct gcov_info): Adjust.
* gcov.c (read_count_file): Adjust.
(output_lines): Adjust.
* libgcov.c (gcov_exit): Adjust.
(__gcov_flush): Adjust.
* mklibgcc.in (libgcc2_c_dep): Add gcov headers.
* predict.c (maybe_hot_bb_p, probably_cold_bb_p,
probably_never_executed_bb_p, compute_frequency_function): Adjust
profile_info use.
* profile.c (struct counts_entry): Remove.
(profile_info): Define here.
(get_exec_counts): Adjust get_coverage_counts call.
(compute_branch_probablilities): Remove find_counters_section
call.
(gen_edge_profiler): Adjust coverage_counter_ref call.
* tracer.c (tail_duplicate): Adjust profile_info use.
2003-04-23 Roger Sayle <roger@eyesopen.com> 2003-04-23 Roger Sayle <roger@eyesopen.com>
PR optimization/10339 PR optimization/10339
......
...@@ -1112,9 +1112,9 @@ LIBGCC_DEPS = $(GCC_PASSES) $(LANGUAGES) stmp-int-hdrs $(STMP_FIXPROTO) \ ...@@ -1112,9 +1112,9 @@ LIBGCC_DEPS = $(GCC_PASSES) $(LANGUAGES) stmp-int-hdrs $(STMP_FIXPROTO) \
$(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs \ $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs \
tsystem.h $(FPBIT) $(DPBIT) $(TPBIT) $(LIB2ADD) \ tsystem.h $(FPBIT) $(DPBIT) $(TPBIT) $(LIB2ADD) \
$(LIB2ADD_ST) $(LIB2ADDEH) $(LIB2ADDEHDEP) $(EXTRA_PARTS) \ $(LIB2ADD_ST) $(LIB2ADDEH) $(LIB2ADDEHDEP) $(EXTRA_PARTS) \
$(srcdir)/config/$(LIB1ASMSRC) $(srcdir)/config/$(LIB1ASMSRC) gcov-io.h gcov-io.c gcov-iov.h
libgcov.a: libgcc.a; @true libgcov.a: $(LIBGCC_DEPS); @true
libgcc.a: $(LIBGCC_DEPS) libgcc.a: $(LIBGCC_DEPS)
$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \ $(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
......
...@@ -155,6 +155,10 @@ typedef struct edge_def { ...@@ -155,6 +155,10 @@ typedef struct edge_def {
#define EDGE_COMPLEX (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH) #define EDGE_COMPLEX (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL | EDGE_EH)
/* Counter summary from the last set of coverage counts read by
profile.c. */
extern const struct gcov_ctr_summary *profile_info;
/* Declared in cfgloop.h. */ /* Declared in cfgloop.h. */
struct loop; struct loop;
struct loops; struct loops;
......
...@@ -23,50 +23,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -23,50 +23,14 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "gcov-io.h" #include "gcov-io.h"
/* The number of different counter sections. */
#define MAX_COUNTER_SECTIONS 1
/* Info about number of counters in the section. */
struct section_info
{
unsigned tag; /* Section tag. */
int present; /* Are the data from this section read into gcc? */
int n_counters; /* Total number of counters. */
int n_counters_now; /* Number of counters in the current function. */
};
struct profile_info
{
/* Information about numbers of counters in counter sections, for
allocating the storage and storing the sizes. */
unsigned n_sections;
struct section_info section_info[MAX_COUNTER_SECTIONS];
/* Checksum of the cfg. Used for 'identification' of code.
Used by final. */
unsigned current_function_cfg_checksum;
/* Max. value of counter in program corresponding to the profile data
for the current function. */
gcov_type max_counter_in_program;
/* The number of profiles merged to form the profile data for the current
function. */
int count_profiles_merged;
};
extern struct profile_info profile_info;
extern void coverage_init (const char *); extern void coverage_init (const char *);
extern void coverage_finish (void); extern void coverage_finish (void);
extern void coverage_end_function (void); extern void coverage_end_function (void);
extern int coverage_begin_output (void); extern int coverage_begin_output (void);
extern rtx coverage_counter_ref (unsigned /*tag*/, unsigned/*num*/);
gcov_type *get_coverage_counts (unsigned /*tag*/, unsigned /*expected*/);
struct section_info *find_counters_section PARAMS ((unsigned));
extern rtx coverage_counter_ref (unsigned /*counter*/, unsigned/*num*/);
extern gcov_type *get_coverage_counts (unsigned /*counter*/,
unsigned /*expected*/,
const struct gcov_ctr_summary **);
#endif #endif
...@@ -35,7 +35,7 @@ static void tag_function PARAMS ((const char *, unsigned, unsigned)); ...@@ -35,7 +35,7 @@ static void tag_function PARAMS ((const char *, unsigned, unsigned));
static void tag_blocks PARAMS ((const char *, unsigned, unsigned)); static void tag_blocks PARAMS ((const char *, unsigned, unsigned));
static void tag_arcs PARAMS ((const char *, unsigned, unsigned)); static void tag_arcs PARAMS ((const char *, unsigned, unsigned));
static void tag_lines PARAMS ((const char *, unsigned, unsigned)); static void tag_lines PARAMS ((const char *, unsigned, unsigned));
static void tag_arc_counts PARAMS ((const char *, unsigned, unsigned)); static void tag_counters PARAMS ((const char *, unsigned, unsigned));
static void tag_summary PARAMS ((const char *, unsigned, unsigned)); static void tag_summary PARAMS ((const char *, unsigned, unsigned));
extern int main PARAMS ((int, char **)); extern int main PARAMS ((int, char **));
...@@ -59,15 +59,13 @@ static const tag_format_t tag_table[] = ...@@ -59,15 +59,13 @@ static const tag_format_t tag_table[] =
{ {
{0, "NOP", NULL}, {0, "NOP", NULL},
{0, "UNKNOWN", NULL}, {0, "UNKNOWN", NULL},
{0, "COUNTERS", tag_counters},
{GCOV_TAG_FUNCTION, "FUNCTION", tag_function}, {GCOV_TAG_FUNCTION, "FUNCTION", tag_function},
{GCOV_TAG_BLOCKS, "BLOCKS", tag_blocks}, {GCOV_TAG_BLOCKS, "BLOCKS", tag_blocks},
{GCOV_TAG_ARCS, "ARCS", tag_arcs}, {GCOV_TAG_ARCS, "ARCS", tag_arcs},
{GCOV_TAG_LINES, "LINES", tag_lines}, {GCOV_TAG_LINES, "LINES", tag_lines},
{GCOV_TAG_ARC_COUNTS, "ARC_COUNTS", tag_arc_counts},
{GCOV_TAG_OBJECT_SUMMARY, "OBJECT_SUMMARY", tag_summary}, {GCOV_TAG_OBJECT_SUMMARY, "OBJECT_SUMMARY", tag_summary},
{GCOV_TAG_PROGRAM_SUMMARY, "PROGRAM_SUMMARY", tag_summary}, {GCOV_TAG_PROGRAM_SUMMARY, "PROGRAM_SUMMARY", tag_summary},
{GCOV_TAG_PLACEHOLDER_SUMMARY, "PROGRAM_PLACEHOLDER", tag_summary},
{GCOV_TAG_INCORRECT_SUMMARY, "PROGRAM_INCORRECT", tag_summary},
{0, NULL, NULL} {0, NULL, NULL}
}; };
...@@ -208,7 +206,7 @@ dump_file (filename) ...@@ -208,7 +206,7 @@ dump_file (filename)
for (format = tag_table; format->name; format++) for (format = tag_table; format->name; format++)
if (format->tag == tag) if (format->tag == tag)
goto found; goto found;
format = &tag_table[1]; format = &tag_table[GCOV_TAG_IS_COUNTER (tag) ? 2 : 1];
found:; found:;
if (tag) if (tag)
{ {
...@@ -364,14 +362,16 @@ tag_lines (filename, tag, length) ...@@ -364,14 +362,16 @@ tag_lines (filename, tag, length)
} }
static void static void
tag_arc_counts (filename, tag, length) tag_counters (filename, tag, length)
const char *filename ATTRIBUTE_UNUSED; const char *filename ATTRIBUTE_UNUSED;
unsigned tag ATTRIBUTE_UNUSED; unsigned tag ATTRIBUTE_UNUSED;
unsigned length ATTRIBUTE_UNUSED; unsigned length ATTRIBUTE_UNUSED;
{ {
static const char *const counter_names[] = GCOV_COUNTER_NAMES;
unsigned n_counts = length / 8; unsigned n_counts = length / 8;
printf (" %u counts", n_counts); printf (" %s %u counts",
counter_names[GCOV_COUNTER_FOR_TAG (tag)], n_counts);
if (flag_dump_contents) if (flag_dump_contents)
{ {
unsigned ix; unsigned ix;
...@@ -395,20 +395,21 @@ tag_summary (filename, tag, length) ...@@ -395,20 +395,21 @@ tag_summary (filename, tag, length)
unsigned length ATTRIBUTE_UNUSED; unsigned length ATTRIBUTE_UNUSED;
{ {
struct gcov_summary summary; struct gcov_summary summary;
unsigned ix;
gcov_read_summary (&summary);
gcov_read_summary (&summary);
printf (" checksum=0x%08x", summary.checksum); printf (" checksum=0x%08x", summary.checksum);
printf ("\n%s:\t\truns=%u, arcs=%u", filename, for (ix = 0; ix != GCOV_COUNTERS; ix++)
summary.runs, summary.arcs); {
printf ("\n%s:\t\tarc_sum=", filename); printf ("\n%sL\t\tcounts=%u, runs=%u", filename,
printf (HOST_WIDEST_INT_PRINT_DEC, summary.ctrs[ix].num, summary.ctrs[ix].runs);
(HOST_WIDEST_INT)summary.arc_sum);
printf (", arc_max_one="); printf (", sum_all=" HOST_WIDEST_INT_PRINT_DEC,
printf (HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT)summary.ctrs[ix].sum_all);
(HOST_WIDEST_INT)summary.arc_max_one); printf (", run_max=" HOST_WIDEST_INT_PRINT_DEC,
printf (", sum_max="); (HOST_WIDEST_INT)summary.ctrs[ix].run_max);
printf (HOST_WIDEST_INT_PRINT_DEC, printf (", sum_max=" HOST_WIDEST_INT_PRINT_DEC,
(HOST_WIDEST_INT)summary.arc_sum_max); (HOST_WIDEST_INT)summary.ctrs[ix].sum_max);
}
} }
...@@ -305,15 +305,20 @@ gcov_write_length (unsigned long position) ...@@ -305,15 +305,20 @@ gcov_write_length (unsigned long position)
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_write_summary (unsigned tag, const struct gcov_summary *summary) gcov_write_summary (unsigned tag, const struct gcov_summary *summary)
{ {
unsigned ix;
const struct gcov_ctr_summary *csum;
unsigned long base; unsigned long base;
base = gcov_write_tag (tag); base = gcov_write_tag (tag);
gcov_write_unsigned (summary->checksum); gcov_write_unsigned (summary->checksum);
gcov_write_unsigned (summary->runs); for (csum = summary->ctrs, ix = GCOV_COUNTERS; ix--; csum++)
gcov_write_unsigned (summary->arcs); {
gcov_write_counter (summary->arc_sum); gcov_write_unsigned (csum->num);
gcov_write_counter (summary->arc_max_one); gcov_write_unsigned (csum->runs);
gcov_write_counter (summary->arc_sum_max); gcov_write_counter (csum->sum_all);
gcov_write_counter (csum->run_max);
gcov_write_counter (csum->sum_max);
}
gcov_write_length (base); gcov_write_length (base);
} }
#endif /* IN_LIBGCOV */ #endif /* IN_LIBGCOV */
...@@ -406,15 +411,20 @@ gcov_read_string () ...@@ -406,15 +411,20 @@ gcov_read_string ()
GCOV_LINKAGE void GCOV_LINKAGE void
gcov_read_summary (struct gcov_summary *summary) gcov_read_summary (struct gcov_summary *summary)
{ {
unsigned ix;
struct gcov_ctr_summary *csum;
summary->checksum = gcov_read_unsigned (); summary->checksum = gcov_read_unsigned ();
summary->runs = gcov_read_unsigned (); for (csum = summary->ctrs, ix = GCOV_COUNTERS; ix--; csum++)
summary->arcs = gcov_read_unsigned (); {
summary->arc_sum = gcov_read_counter (); csum->num = gcov_read_unsigned ();
summary->arc_max_one = gcov_read_counter (); csum->runs = gcov_read_unsigned ();
summary->arc_sum_max = gcov_read_counter (); csum->sum_all = gcov_read_counter ();
csum->run_max = gcov_read_counter ();
csum->sum_max = gcov_read_counter ();
}
} }
#if IN_GCOV > 0 #if IN_GCOV > 0
/* Return the modification time of the current gcov file. */ /* Return the modification time of the current gcov file. */
......
...@@ -127,8 +127,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -127,8 +127,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
function-data: announce_function arc_counts function-data: announce_function arc_counts
announce_function: header string:name int32:checksum announce_function: header string:name int32:checksum
arc_counts: header int64:count* arc_counts: header int64:count*
summary: in32:checksum int32:runs int32:arcs int64:sum int64:max \ summary: int32:checksum {count-summary}GCOV_COUNTERS
int64:sum_max count-summary: int32:num int32:runs int64:sum
int64:max int64:sum_max
The ANNOUNCE_FUNCTION record is the same as that in the BBG file, The ANNOUNCE_FUNCTION record is the same as that in the BBG file,
but without the source location. but without the source location.
...@@ -160,6 +161,11 @@ typedef long gcov_type; ...@@ -160,6 +161,11 @@ typedef long gcov_type;
#else #else
typedef long long gcov_type; typedef long long gcov_type;
#endif #endif
#if defined (TARGET_HAS_F_SETLKW)
#define GCOV_LOCKED 1
#else
#define GCOV_LOCKED 0
#endif
#endif /* IN_LIBGCOV */ #endif /* IN_LIBGCOV */
#if IN_GCOV #if IN_GCOV
typedef HOST_WIDEST_INT gcov_type; typedef HOST_WIDEST_INT gcov_type;
...@@ -201,11 +207,26 @@ typedef HOST_WIDEST_INT gcov_type; ...@@ -201,11 +207,26 @@ typedef HOST_WIDEST_INT gcov_type;
#define GCOV_TAG_BLOCKS ((unsigned)0x01410000) #define GCOV_TAG_BLOCKS ((unsigned)0x01410000)
#define GCOV_TAG_ARCS ((unsigned)0x01430000) #define GCOV_TAG_ARCS ((unsigned)0x01430000)
#define GCOV_TAG_LINES ((unsigned)0x01450000) #define GCOV_TAG_LINES ((unsigned)0x01450000)
#define GCOV_TAG_ARC_COUNTS ((unsigned)0x01a10000) #define GCOV_TAG_COUNTER_BASE ((unsigned)0x01a10000) /* First counter */
#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_PLACEHOLDER_SUMMARY ((unsigned)0xa5000000)
#define GCOV_TAG_INCORRECT_SUMMARY ((unsigned)0xa7000000) /* Counters that are collected. */
#define GCOV_COUNTER_ARCS 0 /* Arc transitions. */
#define GCOV_COUNTERS 1
/* A list of human readable names of the counters */
#define GCOV_COUNTER_NAMES {"arcs"}
/* Convert a counter index to a tag. */
#define GCOV_TAG_FOR_COUNTER(COUNT) \
(GCOV_TAG_COUNTER_BASE + ((COUNT) << 17))
/* Convert a tag to a counter. */
#define GCOV_COUNTER_FOR_TAG(TAG) \
(((TAG) - GCOV_TAG_COUNTER_BASE) >> 17)
/* Check whether a tag is a counter tag. */
#define GCOV_TAG_IS_COUNTER(TAG) \
(!((TAG) & 0xFFFF) && GCOV_COUNTER_FOR_TAG (TAG) < GCOV_COUNTERS)
/* The tag level mask has 1's in the position of the inner levels, & /* The tag level mask has 1's in the position of the inner levels, &
the lsb of the current level, and zero on the current and outer the lsb of the current level, and zero on the current and outer
...@@ -231,44 +252,43 @@ typedef HOST_WIDEST_INT gcov_type; ...@@ -231,44 +252,43 @@ typedef HOST_WIDEST_INT gcov_type;
/* Structured records. */ /* Structured records. */
/* Cumulative counter data. */
struct gcov_ctr_summary
{
unsigned num; /* number of counters. */
unsigned runs; /* number of program runs */
gcov_type sum_all; /* sum of all counters accumulated. */
gcov_type run_max; /* maximum value on a single run. */
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 */ unsigned checksum; /* checksum of program */
unsigned runs; /* number of program runs */ struct gcov_ctr_summary ctrs[GCOV_COUNTERS];
unsigned arcs; /* number of instrumented arcs */
gcov_type arc_sum; /* sum of all arc counters */
gcov_type arc_max_one; /* max counter on any one run */
gcov_type arc_sum_max; /* sum of max_one */
}; };
/* Structures embedded in coveraged program. The structures generated /* Structures embedded in coveraged program. The structures generated
by write_profile must match these. */ by write_profile must match these. */
/* Information about section of counters for a function. */
struct gcov_counter_section
{
unsigned tag; /* Tag of the section. */
unsigned n_counters; /* Number of counters in the section. */
};
#if IN_LIBGCOV #if IN_LIBGCOV
/* Information about section of counters for an object file. */ /* Information about a single function. This uses the trailing array
struct gcov_counter_section_data idiom. The number of counters is determined from the counter_mask
in gcov_info. We hold an array of function info, so have to
explicitly calculate the correct array stride. */
struct gcov_fn_info
{ {
unsigned tag; /* Tag of the section. */ const char *name; /* (mangled) name of function */
unsigned n_counters; /* Number of counters in the section. */ unsigned checksum; /* function checksum */
gcov_type *counters; /* The data. */ unsigned n_ctrs[0]; /* instrumented counters */
}; };
/* Information about a single function. */ /* Information about counters. */
struct gcov_function_info struct gcov_ctr_info
{ {
const char *name; /* (mangled) name of function */ unsigned num; /* number of counters. */
unsigned checksum; /* function checksum */ gcov_type *values; /* their values. */
unsigned n_counter_sections; /* Number of types of counters */
const struct gcov_counter_section *counter_sections;
/* The section descriptions */
}; };
/* Information about a single object file. */ /* Information about a single object file. */
...@@ -278,14 +298,15 @@ struct gcov_info ...@@ -278,14 +298,15 @@ struct gcov_info
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 */
long wkspc; /* libgcc workspace */
unsigned n_functions; /* number of functions */ unsigned n_functions; /* number of functions */
const struct gcov_function_info *functions; /* table of functions */ const struct gcov_fn_info *functions; /* table of functions */
unsigned n_counter_sections; /* Number of types of counters */ unsigned ctr_mask; /* mask of counters instrumented. */
const struct gcov_counter_section_data *counter_sections; struct gcov_ctr_info counts[0]; /* count data. The number of bits
/* The data to be put into the sections. */ set in the ctr_mask field
determines how big this array
is. */
}; };
/* Register a new object file module. */ /* Register a new object file module. */
......
...@@ -1011,8 +1011,7 @@ read_count_file () ...@@ -1011,8 +1011,7 @@ read_count_file ()
if (tag == GCOV_TAG_OBJECT_SUMMARY) if (tag == GCOV_TAG_OBJECT_SUMMARY)
gcov_read_summary (&object_summary); gcov_read_summary (&object_summary);
else if (tag == GCOV_TAG_PROGRAM_SUMMARY else if (tag == GCOV_TAG_PROGRAM_SUMMARY)
|| tag == GCOV_TAG_INCORRECT_SUMMARY)
program_count++; program_count++;
else if (tag == GCOV_TAG_FUNCTION) else if (tag == GCOV_TAG_FUNCTION)
{ {
...@@ -1045,7 +1044,7 @@ read_count_file () ...@@ -1045,7 +1044,7 @@ read_count_file ()
goto cleanup; goto cleanup;
} }
} }
else if (tag == GCOV_TAG_ARC_COUNTS && fn) else if (tag == GCOV_TAG_FOR_COUNTER (GCOV_COUNTER_ARCS) && fn)
{ {
if (length != 8 * fn->num_counts) if (length != 8 * fn->num_counts)
goto mismatch; goto mismatch;
...@@ -1801,7 +1800,8 @@ output_lines (gcov_file, src) ...@@ -1801,7 +1800,8 @@ output_lines (gcov_file, src)
fprintf (gcov_file, "%9s:%5d:Source:%s\n", "-", 0, src->name); fprintf (gcov_file, "%9s:%5d:Source:%s\n", "-", 0, src->name);
fprintf (gcov_file, "%9s:%5d:Graph:%s\n", "-", 0, bbg_file_name); fprintf (gcov_file, "%9s:%5d:Graph:%s\n", "-", 0, bbg_file_name);
fprintf (gcov_file, "%9s:%5d:Data:%s\n", "-", 0, da_file_name); fprintf (gcov_file, "%9s:%5d:Data:%s\n", "-", 0, da_file_name);
fprintf (gcov_file, "%9s:%5d:Runs:%u\n", "-", 0, object_summary.runs); fprintf (gcov_file, "%9s:%5d:Runs:%u\n", "-", 0,
object_summary.ctrs[GCOV_COUNTER_ARCS].runs);
fprintf (gcov_file, "%9s:%5d:Programs:%u\n", "-", 0, program_count); fprintf (gcov_file, "%9s:%5d:Programs:%u\n", "-", 0, program_count);
source_file = fopen (src->name, "r"); source_file = fopen (src->name, "r");
......
...@@ -75,7 +75,7 @@ make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \ ...@@ -75,7 +75,7 @@ make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'" $LIB2ADDEHDEP" libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h'" $LIB2ADDEHDEP"
# Dependencies for libgcov.c # Dependencies for libgcov.c
libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h' libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h gbl-ctors.h config.status stmp-int-hdrs tsystem.h gcov-io.h gcov-io.c gcov-iov.h'
# Dependencies for fp-bit.c # Dependencies for fp-bit.c
fpbit_c_dep='stmp-dirs config.status tsystem.h' fpbit_c_dep='stmp-dirs config.status tsystem.h'
......
...@@ -120,11 +120,9 @@ bool ...@@ -120,11 +120,9 @@ bool
maybe_hot_bb_p (bb) maybe_hot_bb_p (bb)
basic_block bb; basic_block bb;
{ {
if (profile_info.count_profiles_merged if (profile_info && flag_branch_probabilities
&& flag_branch_probabilities
&& (bb->count && (bb->count
< profile_info.max_counter_in_program < profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
/ PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
return false; return false;
if (bb->frequency < BB_FREQ_MAX / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)) if (bb->frequency < BB_FREQ_MAX / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION))
return false; return false;
...@@ -137,11 +135,9 @@ bool ...@@ -137,11 +135,9 @@ bool
probably_cold_bb_p (bb) probably_cold_bb_p (bb)
basic_block bb; basic_block bb;
{ {
if (profile_info.count_profiles_merged if (profile_info && flag_branch_probabilities
&& flag_branch_probabilities
&& (bb->count && (bb->count
< profile_info.max_counter_in_program < profile_info->sum_max / PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
/ PARAM_VALUE (HOT_BB_COUNT_FRACTION)))
return true; return true;
if (bb->frequency < BB_FREQ_MAX / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION)) if (bb->frequency < BB_FREQ_MAX / PARAM_VALUE (HOT_BB_FREQUENCY_FRACTION))
return true; return true;
...@@ -153,10 +149,8 @@ bool ...@@ -153,10 +149,8 @@ bool
probably_never_executed_bb_p (bb) probably_never_executed_bb_p (bb)
basic_block bb; basic_block bb;
{ {
if (profile_info.count_profiles_merged if (profile_info && flag_branch_probabilities)
&& flag_branch_probabilities) return ((bb->count + profile_info->runs / 2) / profile_info->runs) == 0;
return ((bb->count + profile_info.count_profiles_merged / 2)
/ profile_info.count_profiles_merged) == 0;
return false; return false;
} }
...@@ -1266,8 +1260,7 @@ compute_function_frequency () ...@@ -1266,8 +1260,7 @@ compute_function_frequency ()
{ {
basic_block bb; basic_block bb;
if (!profile_info.count_profiles_merged if (!profile_info || !flag_branch_probabilities)
|| !flag_branch_probabilities)
return; return;
cfun->function_frequency = FUNCTION_FREQUENCY_UNLIKELY_EXECUTED; cfun->function_frequency = FUNCTION_FREQUENCY_UNLIKELY_EXECUTED;
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
......
...@@ -81,26 +81,6 @@ struct bb_info { ...@@ -81,26 +81,6 @@ struct bb_info {
gcov_type pred_count; gcov_type pred_count;
}; };
/* Counts information for a function. */
typedef struct counts_entry
{
/* We hash by */
char *function_name;
unsigned section;
/* Store */
unsigned checksum;
unsigned n_counts;
gcov_type *counts;
unsigned merged;
gcov_type max_counter;
gcov_type max_counter_sum;
/* Workspace */
struct counts_entry *chain;
} counts_entry_t;
#define EDGE_INFO(e) ((struct edge_info *) (e)->aux) #define EDGE_INFO(e) ((struct edge_info *) (e)->aux)
#define BB_INFO(b) ((struct bb_info *) (b)->aux) #define BB_INFO(b) ((struct bb_info *) (b)->aux)
...@@ -110,6 +90,10 @@ typedef struct counts_entry ...@@ -110,6 +90,10 @@ typedef struct counts_entry
: ((bb) == EXIT_BLOCK_PTR \ : ((bb) == EXIT_BLOCK_PTR \
? last_basic_block + 1 : (bb)->index + 1)) ? last_basic_block + 1 : (bb)->index + 1))
/* Counter summary from the last set of coverage counts read. */
const struct gcov_ctr_summary *profile_info;
/* Collect statistics on the performance of this pass for the entire source /* Collect statistics on the performance of this pass for the entire source
file. */ file. */
...@@ -195,16 +179,13 @@ get_exec_counts () ...@@ -195,16 +179,13 @@ get_exec_counts ()
num_edges++; num_edges++;
} }
counts = get_coverage_counts (GCOV_TAG_ARC_COUNTS, num_edges); counts = get_coverage_counts (GCOV_COUNTER_ARCS, num_edges, &profile_info);
if (!counts) if (!counts)
return NULL; return NULL;
if (rtl_dump_file) if (rtl_dump_file && profile_info)
{ fprintf(rtl_dump_file, "Merged %u profiles with maximal count %u.\n",
fprintf(rtl_dump_file, "Merged %i profiles with maximal count %i.\n", profile_info->runs, (unsigned) profile_info->sum_max);
profile_info.count_profiles_merged,
(int)profile_info.max_counter_in_program);
}
return counts; return counts;
} }
...@@ -547,7 +528,6 @@ compute_branch_probabilities () ...@@ -547,7 +528,6 @@ compute_branch_probabilities ()
} }
free_aux_for_blocks (); free_aux_for_blocks ();
find_counters_section (GCOV_TAG_ARC_COUNTS)->present = 1;
} }
/* Instrument and/or analyze program behavior based on program flow graph. /* Instrument and/or analyze program behavior based on program flow graph.
...@@ -1013,7 +993,7 @@ static rtx ...@@ -1013,7 +993,7 @@ static rtx
gen_edge_profiler (edgeno) gen_edge_profiler (edgeno)
int edgeno; int edgeno;
{ {
rtx ref = coverage_counter_ref (GCOV_TAG_ARC_COUNTS, edgeno); rtx ref = coverage_counter_ref (GCOV_COUNTER_ARCS, edgeno);
rtx tmp; rtx tmp;
enum machine_mode mode = GET_MODE (ref); enum machine_mode mode = GET_MODE (ref);
rtx sequence; rtx sequence;
......
...@@ -211,7 +211,7 @@ tail_duplicate () ...@@ -211,7 +211,7 @@ tail_duplicate ()
int max_dup_insns; int max_dup_insns;
basic_block bb; basic_block bb;
if (profile_info.count_profiles_merged && flag_branch_probabilities) if (profile_info && flag_branch_probabilities)
probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY_FEEDBACK); probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY_FEEDBACK);
else else
probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY); probability_cutoff = PARAM_VALUE (TRACER_MIN_BRANCH_PROBABILITY);
...@@ -232,7 +232,7 @@ tail_duplicate () ...@@ -232,7 +232,7 @@ tail_duplicate ()
weighted_insns += n * bb->frequency; weighted_insns += n * bb->frequency;
} }
if (profile_info.count_profiles_merged && flag_branch_probabilities) if (profile_info && flag_branch_probabilities)
cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE_FEEDBACK); cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE_FEEDBACK);
else else
cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE); cover_insns = PARAM_VALUE (TRACER_DYNAMIC_COVERAGE);
......
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