make gcov counters 64bit

Jan Hubicka jh@suse.cz
Thu Jun 14 07:14:00 GMT 2001


Hi,
for futher testing of branch prediction it seems to be imprtant to remove
random garbage caused by overflows of counters.  Todays computers are just too
fast to overflow 32bit counter.

This patch is update of almost exactly one year old patch. It is long but
mindless and changes gcov to use 64bit integer if available.

Thu Jun 29 14:48:32 CEST 2000  Jan Hubicka  <jh@suse.cz>

	* basic-block.h (gcov_type): Define.
	(struct edge_def): Use gcov_type for count field.
	(struct basic_block_def): Likewise.
	* defaults.h (GCOV_TYPE_SIZE): Define.
	* final.c (end_final): Use GCOV_TYPE_SIZE.
	* flow.c (dump_edge_info, dump_flow_info, dump_bb): Print count fields
	using HOST_WIDEST_INT_PRINT_DEC.
	* gcov-io.h (__fetch_gcov_type, __store_gcov_type, __read_gcov_type,
	__write_gcov_type): New.
	(store_long): Remove.
	* gcov.c (gcov_type): Set default.
	(struct adj_list): Use gcov_type for arc_count.
	(bb_info): Use gcov_type for succ_count, pred_count and exec_count.
	(create_program_flow_graph): Read arc_count properly.
	(solve_program_flow_graph): 'total' is gcov_type.
	(output_data): Line_counts is gcov_type, print it properly.
	* libgcc2.c (struct bb): Counts is gcov_type.
	(__bb_exit_func): Use __read_gcov_type and __write_gcov_type.
	* profile.c (LONG_TYPE_SIZE, LONG_LONG_TYPE_SIZE): Set default.
	(GCOV_TYPE_SIZE): Define.
	(struct bb_info): succ_count and pred_count is gcov_type.
	(compute_branch_probabilities): Use __read_gcov_type,
	print read edges to the dump file.
	(total): Is gcov_type.
	(gen_edge_profiler): Use GCOV_TYPE_SIZE.

Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/basic-block.h,v
retrieving revision 1.91
diff -c -3 -p -r1.91 basic-block.h
*** basic-block.h	2001/06/08 21:54:10	1.91
--- basic-block.h	2001/06/14 14:07:01
*************** do {									\
*** 111,116 ****
--- 111,119 ----
     be done, other than zero the statistics on the first allocation.  */
  #define MAX_REGNO_REG_SET(NUM_REGS, NEW_P, RENUMBER_P) 
  
+ /* Type we use to hold basic block counters.  Should be at least 64bit.  */
+ typedef HOST_WIDEST_INT gcov_type;
+ 
  /* Control flow edge information.  */
  typedef struct edge_def {
    /* Links through the predecessor and successor lists.  */
*************** typedef struct edge_def {
*** 127,133 ****
  
    int flags;			/* see EDGE_* below  */
    int probability;		/* biased by REG_BR_PROB_BASE */
!   int count;			/* Expected number of executions calculated
  				   in profile.c  */
  } *edge;
  
--- 130,136 ----
  
    int flags;			/* see EDGE_* below  */
    int probability;		/* biased by REG_BR_PROB_BASE */
!   gcov_type count;		/* Expected number of executions calculated
  				   in profile.c  */
  } *edge;
  
*************** typedef struct basic_block_def {
*** 201,207 ****
    int loop_depth;
  
    /* Expected number of executions: calculated in profile.c.  */
!   int count;
  } *basic_block;
  
  /* Number of basic blocks in the current function.  */
--- 204,210 ----
    int loop_depth;
  
    /* Expected number of executions: calculated in profile.c.  */
!   gcov_type count;
  } *basic_block;
  
  /* Number of basic blocks in the current function.  */
Index: defaults.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/defaults.h,v
retrieving revision 1.41
diff -c -3 -p -r1.41 defaults.h
*** defaults.h	2001/05/26 01:31:34	1.41
--- defaults.h	2001/06/14 14:07:03
*************** do {								\
*** 297,302 ****
--- 297,318 ----
  #define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
  #endif
  
+ /* Type used by GCOV counters.  Use 64bit data type if target supports
+    it.  */
+ #if LONG_TYPE_SIZE == 64 || LONG_LONG_TYPE_SIZE == 64
+ #define GCOV_TYPE_SIZE 64
+ #else
+ #define GCOV_TYPE_SIZE LONG_LONG_TYPE_SIZE
+ #endif
+ 
+ /* Type we use for GCOV profiling.
+    When there is 64 integer type, go for it.  */
+ #if LONG_TYPE_SIZE == 64 || LONG_LONG_TYPE_SIZE == 64
+ #define GCOV_TYPE_SIZE 64
+ #else
+ #define GCOV_TYPE_SIZE LONG_TYPE_SIZE
+ #endif
+ 
  /* By default, the preprocessor should be invoked the same way in C++
     as in C.  */
  #ifndef CPLUSPLUS_CPP_SPEC
Index: final.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/final.c,v
retrieving revision 1.176
diff -c -3 -p -r1.176 final.c
*** final.c	2001/06/08 19:52:06	1.176
--- final.c	2001/06/14 14:07:05
*************** end_final (filename)
*** 298,309 ****
        struct bb_list *ptr;
        struct bb_str *sptr;
        int long_bytes = LONG_TYPE_SIZE / BITS_PER_UNIT;
        int pointer_bytes = POINTER_SIZE / BITS_PER_UNIT;
  
        if (profile_block_flag)
  	size = long_bytes * count_basic_blocks;
        else
! 	size = long_bytes * count_instrumented_edges;
        rounded = size;
  
        rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
--- 298,310 ----
        struct bb_list *ptr;
        struct bb_str *sptr;
        int long_bytes = LONG_TYPE_SIZE / BITS_PER_UNIT;
+       int gcov_type_bytes = GCOV_TYPE_SIZE / BITS_PER_UNIT;
        int pointer_bytes = POINTER_SIZE / BITS_PER_UNIT;
  
        if (profile_block_flag)
  	size = long_bytes * count_basic_blocks;
        else
! 	size = gcov_type_bytes * count_instrumented_edges;
        rounded = size;
  
        rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.398
diff -c -3 -p -r1.398 flow.c
*** flow.c	2001/06/08 21:54:10	1.398
--- flow.c	2001/06/14 14:07:07
*************** dump_flow_info (file)
*** 6345,6352 ****
        register basic_block bb = BASIC_BLOCK (i);
        register edge e;
  
!       fprintf (file, "\nBasic block %d: first insn %d, last %d, loop_depth %d, count %d.\n",
! 	       i, INSN_UID (bb->head), INSN_UID (bb->end), bb->loop_depth, bb->count);
  
        fprintf (file, "Predecessors: ");
        for (e = bb->pred; e; e = e->pred_next)
--- 6345,6354 ----
        register basic_block bb = BASIC_BLOCK (i);
        register edge e;
  
!       fprintf (file, "\nBasic block %d: first insn %d, last %d, loop_depth %d, count ",
! 	       i, INSN_UID (bb->head), INSN_UID (bb->end), bb->loop_depth);
!       fprintf (file, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) bb->count);
!       fprintf (file, ".\n");
  
        fprintf (file, "Predecessors: ");
        for (e = bb->pred; e; e = e->pred_next)
*************** dump_edge_info (file, e, do_succ)
*** 6390,6396 ****
      fprintf (file, " %d", side->index);
  
    if (e->count)
!     fprintf (file, " count:%d", e->count);
  
    if (e->flags)
      {
--- 6392,6401 ----
      fprintf (file, " %d", side->index);
  
    if (e->count)
!     {
!       fprintf (file, " count:");
!       fprintf (file, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) e->count);
!     }
  
    if (e->flags)
      {
*************** dump_bb (bb, outf)
*** 6430,6437 ****
    rtx last;
    edge e;
  
!   fprintf (outf, ";; Basic block %d, loop depth %d, count %d",
  	   bb->index, bb->loop_depth, bb->count);
    putc ('\n', outf);
  
    fputs (";; Predecessors: ", outf);
--- 6435,6443 ----
    rtx last;
    edge e;
  
!   fprintf (outf, ";; Basic block %d, loop depth %d, count ",
  	   bb->index, bb->loop_depth, bb->count);
+   fprintf (outf, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) bb->count);
    putc ('\n', outf);
  
    fputs (";; Predecessors: ", outf);
Index: gcov-io.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcov-io.h,v
retrieving revision 1.11
diff -c -3 -p -r1.11 gcov-io.h
*** gcov-io.h	2001/05/26 01:31:34	1.11
--- gcov-io.h	2001/06/14 14:07:07
*************** Boston, MA 02111-1307, USA.  */
*** 25,33 ****
  #include <sys/types.h>
  
  static int __fetch_long	PARAMS ((long *, char *, size_t)) ATTRIBUTE_UNUSED;
- static int __store_long PARAMS ((long, char *, size_t)) ATTRIBUTE_UNUSED;
  static int __read_long  PARAMS ((long *, FILE *, size_t)) ATTRIBUTE_UNUSED;
  static int __write_long PARAMS ((long, FILE *, size_t)) ATTRIBUTE_UNUSED;
  
  /* These routines only work for signed values. */
  
--- 25,36 ----
  #include <sys/types.h>
  
  static int __fetch_long	PARAMS ((long *, char *, size_t)) ATTRIBUTE_UNUSED;
  static int __read_long  PARAMS ((long *, FILE *, size_t)) ATTRIBUTE_UNUSED;
  static int __write_long PARAMS ((long, FILE *, size_t)) ATTRIBUTE_UNUSED;
+ static int __fetch_gcov_type PARAMS ((gcov_type *, char *, size_t)) ATTRIBUTE_UNUSED;
+ static int __store_gcov_type PARAMS ((gcov_type, char *, size_t)) ATTRIBUTE_UNUSED;
+ static int __read_gcov_type  PARAMS ((gcov_type *, FILE *, size_t)) ATTRIBUTE_UNUSED;
+ static int __write_gcov_type PARAMS ((gcov_type, FILE *, size_t)) ATTRIBUTE_UNUSED;
  
  /* These routines only work for signed values. */
  
*************** static int __write_long PARAMS ((long, F
*** 36,43 ****
     to store. */
  
  static int
! __store_long (value, dest, bytes)
!      long value;
       char *dest;
       size_t bytes;
  {
--- 39,46 ----
     to store. */
  
  static int
! __store_gcov_type (value, dest, bytes)
!      gcov_type value;
       char *dest;
       size_t bytes;
  {
*************** __store_long (value, dest, bytes)
*** 46,52 ****
  
    if (value < 0)
      {
!       long oldvalue = value;
        value = -value;
        if (oldvalue != -value)
  	return 1;
--- 49,55 ----
  
    if (value < 0)
      {
!       gcov_type oldvalue = value;
        value = -value;
        if (oldvalue != -value)
  	return 1;
*************** __store_long (value, dest, bytes)
*** 71,76 ****
--- 74,102 ----
     will not fit in DEST. */
  
  static int
+ __fetch_gcov_type (dest, source, bytes)
+      gcov_type *dest;
+      char *source;
+      size_t bytes;
+ {
+   gcov_type value = 0;
+   int i;
+ 
+   for (i = bytes - 1; (size_t) i > (sizeof (*dest) - 1); i--)
+     if (source[i] & ((size_t) i == (bytes - 1) ? 127 : 255 ))
+       return 1;
+ 
+   for (; i >= 0; i--)
+     value = value * 256 + (source[i] & ((size_t)i == (bytes - 1) ? 127 : 255));
+ 
+   if ((source[bytes - 1] & 128) && (value > 0))
+     value = - value;
+ 
+   *dest = value;
+   return 0;
+ }
+ 
+ static int
  __fetch_long (dest, source, bytes)
       long *dest;
       char *source;
*************** __fetch_long (dest, source, bytes)
*** 103,108 ****
--- 129,148 ----
     BYTES may be a maximum of 10. */
  
  static int
+ __write_gcov_type (value, file, bytes)
+      gcov_type value;
+      FILE *file;
+      size_t bytes;
+ {
+   char c[10];
+ 
+   if (bytes > 10 || __store_gcov_type (value, c, bytes))
+     return 1;
+   else
+     return fwrite(c, 1, bytes, file) != bytes;
+ }
+ 
+ static int
  __write_long (value, file, bytes)
       long value;
       FILE *file;
*************** __write_long (value, file, bytes)
*** 110,116 ****
  {
    char c[10];
  
!   if (bytes > 10 || __store_long (value, c, bytes))
      return 1;
    else
      return fwrite(c, 1, bytes, file) != bytes;
--- 150,156 ----
  {
    char c[10];
  
!   if (bytes > 10 || __store_gcov_type ((gcov_type)value, c, bytes))
      return 1;
    else
      return fwrite(c, 1, bytes, file) != bytes;
*************** __write_long (value, file, bytes)
*** 124,129 ****
--- 164,183 ----
     data, but the function will read BYTES characters anyway.
  
     BYTES may be a maximum of 10. */
+ 
+ static int
+ __read_gcov_type (dest, file, bytes)
+      gcov_type *dest;
+      FILE *file;
+      size_t bytes;
+ {
+   char c[10];
+ 
+   if (bytes > 10 || fread(c, 1, bytes, file) != bytes)
+     return 1;
+   else
+     return __fetch_gcov_type (dest, c, bytes);
+ }
  
  static int
  __read_long (dest, file, bytes)
Index: gcov.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcov.c,v
retrieving revision 1.29
diff -c -3 -p -r1.29 gcov.c
*** gcov.c	2000/12/17 14:35:05	1.29
--- gcov.c	2001/06/14 14:07:08
*************** Boston, MA 02111-1307, USA.  */
*** 48,53 ****
--- 48,54 ----
  #include "intl.h"
  #undef abort
  
+ typedef HOST_WIDEST_INT gcov_type;
  #include "gcov-io.h"
  
  /* The .bb file format consists of several lists of 4-byte integers
*************** struct sourcefile *sources;
*** 104,110 ****
  struct adj_list {
    int source;
    int target;
!   int arc_count;
    unsigned int count_valid : 1;
    unsigned int on_tree : 1;
    unsigned int fake : 1;
--- 105,111 ----
  struct adj_list {
    int source;
    int target;
!   gcov_type arc_count;
    unsigned int count_valid : 1;
    unsigned int on_tree : 1;
    unsigned int fake : 1;
*************** struct adj_list {
*** 123,131 ****
  struct bb_info {
    struct adj_list *succ;
    struct adj_list *pred;
!   int succ_count;
!   int pred_count;
!   int exec_count;
    unsigned int count_valid : 1;
    unsigned int on_tree : 1;
  #if 0
--- 124,132 ----
  struct bb_info {
    struct adj_list *succ;
    struct adj_list *pred;
!   gcov_type succ_count;
!   gcov_type pred_count;
!   gcov_type exec_count;
    unsigned int count_valid : 1;
    unsigned int on_tree : 1;
  #if 0
*************** create_program_flow_graph (bptr)
*** 579,586 ****
      for (arcptr = bb_graph[i].succ; arcptr; arcptr = arcptr->succ_next)
        if (! arcptr->on_tree)
  	{
! 	  long tmp_count = 0;
! 	  if (da_file && __read_long (&tmp_count, da_file, 8))
  	    abort();
  
  	  arcptr->arc_count = tmp_count;
--- 580,587 ----
      for (arcptr = bb_graph[i].succ; arcptr; arcptr = arcptr->succ_next)
        if (! arcptr->on_tree)
  	{
! 	  gcov_type tmp_count = 0;
! 	  if (da_file && __read_gcov_type (&tmp_count, da_file, 8))
  	    abort();
  
  	  arcptr->arc_count = tmp_count;
*************** static void
*** 594,600 ****
  solve_program_flow_graph (bptr)
       struct bb_info_list *bptr;
  {
!   int passes, changes, total;
    int i;
    struct adj_list *arcptr;
    struct bb_info *bb_graph;
--- 595,602 ----
  solve_program_flow_graph (bptr)
       struct bb_info_list *bptr;
  {
!   int passes, changes;
!   gcov_type total;
    int i;
    struct adj_list *arcptr;
    struct bb_info *bb_graph;
*************** output_data ()
*** 975,981 ****
    int this_file;
    /* An array indexed by line number which indicates how many times that line
       was executed.  */
!   long *line_counts;
    /* An array indexed by line number which indicates whether the line was
       present in the bb file (i.e. whether it had code associate with it).
       Lines never executed are those which both exist, and have zero execution
--- 977,983 ----
    int this_file;
    /* An array indexed by line number which indicates how many times that line
       was executed.  */
!   gcov_type *line_counts;
    /* An array indexed by line number which indicates whether the line was
       present in the bb file (i.e. whether it had code associate with it).
       Lines never executed are those which both exist, and have zero execution
*************** output_data ()
*** 1035,1041 ****
        else
  	source_file_name = s_ptr->name;
  
!       line_counts = (long *) xcalloc (sizeof (long), s_ptr->maxlineno);
        line_exists = xcalloc (1, s_ptr->maxlineno);
        if (output_branch_probs)
  	branch_probs = (struct arcdata **)
--- 1037,1043 ----
        else
  	source_file_name = s_ptr->name;
  
!       line_counts = (gcov_type *) xcalloc (sizeof (gcov_type), s_ptr->maxlineno);
        line_exists = xcalloc (1, s_ptr->maxlineno);
        if (output_branch_probs)
  	branch_probs = (struct arcdata **)
*************** output_data ()
*** 1324,1331 ****
  	      if (line_exists[count])
  		{
  		  if (line_counts[count])
! 		    fprintf (gcov_file, "%12ld    %s", line_counts[count],
! 			     string);
  		  else
  		    fprintf (gcov_file, "      ######    %s", string);
  		}
--- 1326,1337 ----
  	      if (line_exists[count])
  		{
  		  if (line_counts[count])
! 		    {
! 		      char c[20];
! 		      sprintf (c, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT)line_counts[count]);
! 		      fprintf (gcov_file, "%12s    %s", c,
! 			       string);
! 		    }
  		  else
  		    fprintf (gcov_file, "      ######    %s", string);
  		}
Index: libgcc2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/libgcc2.c,v
retrieving revision 1.120
diff -c -3 -p -r1.120 libgcc2.c
*** libgcc2.c	2001/05/14 02:46:22	1.120
--- libgcc2.c	2001/06/14 14:07:09
*************** __eprintf (const char *string, const cha
*** 1263,1274 ****
  
  #ifdef L_bb
  
  /* Structure emitted by -a  */
  struct bb
  {
    long zero_word;
    const char *filename;
!   long *counts;
    long ncounts;
    struct bb *next;
    const unsigned long *addresses;
--- 1263,1281 ----
  
  #ifdef L_bb
  
+ #if LONG_TYPE_SIZE == GCOV_TYPE_SIZE
+ typedef long gcov_type;
+ #else
+ typedef long long gcov_type;
+ #endif
+ 
+ 
  /* Structure emitted by -a  */
  struct bb
  {
    long zero_word;
    const char *filename;
!   gcov_type *counts;
    long ncounts;
    struct bb *next;
    const unsigned long *addresses;
*************** __bb_exit_func (void)
*** 1415,1423 ****
  
  		  for (i = 0; i < n_counts; i++)
  		    {
! 		      long v = 0;
  
! 		      if (__read_long (&v, da_file, 8) != 0)
  			{
  			  fprintf (stderr, "arc profiling: Can't read output file %s.\n",
  				   ptr->filename);
--- 1422,1430 ----
  
  		  for (i = 0; i < n_counts; i++)
  		    {
! 		      gcov_type v = 0;
  
! 		      if (__read_gcov_type (&v, da_file, 8) != 0)
  			{
  			  fprintf (stderr, "arc profiling: Can't read output file %s.\n",
  				   ptr->filename);
*************** __bb_exit_func (void)
*** 1439,1445 ****
  	     That way we can easily verify that the proper source/executable/
  	     data file combination is being used from gcov.  */
  
! 	  if (__write_long (ptr->ncounts, da_file, 8) != 0)
  	    {
  	      
  	      fprintf (stderr, "arc profiling: Error writing output file %s.\n",
--- 1446,1452 ----
  	     That way we can easily verify that the proper source/executable/
  	     data file combination is being used from gcov.  */
  
! 	  if (__write_gcov_type (ptr->ncounts, da_file, 8) != 0)
  	    {
  	      
  	      fprintf (stderr, "arc profiling: Error writing output file %s.\n",
*************** __bb_exit_func (void)
*** 1448,1458 ****
  	  else
  	    {
  	      int j;
! 	      long *count_ptr = ptr->counts;
  	      int ret = 0;
  	      for (j = ptr->ncounts; j > 0; j--)
  		{
! 		  if (__write_long (*count_ptr, da_file, 8) != 0)
  		    {
  		      ret=1;
  		      break;
--- 1455,1465 ----
  	  else
  	    {
  	      int j;
! 	      gcov_type *count_ptr = ptr->counts;
  	      int ret = 0;
  	      for (j = ptr->ncounts; j > 0; j--)
  		{
! 		  if (__write_gcov_type (*count_ptr, da_file, 8) != 0)
  		    {
  		      ret=1;
  		      break;
Index: profile.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/profile.c,v
retrieving revision 1.56
diff -c -3 -p -r1.56 profile.c
*** profile.c	2001/04/23 00:36:26	1.56
--- profile.c	2001/06/14 14:07:09
*************** Boston, MA 02111-1307, USA.  */
*** 43,53 ****
  #include "regs.h"
  #include "expr.h"
  #include "function.h"
- #include "gcov-io.h"
  #include "toplev.h"
  #include "ggc.h"
  #include "hard-reg-set.h"
  #include "basic-block.h"
  
  /* Additional information about the edges we need.  */
  struct edge_info
--- 43,53 ----
  #include "regs.h"
  #include "expr.h"
  #include "function.h"
  #include "toplev.h"
  #include "ggc.h"
  #include "hard-reg-set.h"
  #include "basic-block.h"
+ #include "gcov-io.h"
  
  /* Additional information about the edges we need.  */
  struct edge_info
*************** struct edge_info
*** 59,66 ****
  struct bb_info
    {
      unsigned int count_valid : 1;
!     int succ_count;
!     int pred_count;
    };
  
  #define EDGE_INFO(e)  ((struct edge_info *) (e)->aux)
--- 59,66 ----
  struct bb_info
    {
      unsigned int count_valid : 1;
!     gcov_type succ_count;
!     gcov_type pred_count;
    };
  
  #define EDGE_INFO(e)  ((struct edge_info *) (e)->aux)
*************** compute_branch_probabilities ()
*** 256,263 ****
  	    num_edges++;
  	    if (da_file)
  	      {
! 		long value;
! 		__read_long (&value, da_file, 8);
  		e->count = value;
  	      }
  	    else
--- 256,263 ----
  	    num_edges++;
  	    if (da_file)
  	      {
! 		gcov_type value;
! 		__read_gcov_type (&value, da_file, 8);
  		e->count = value;
  	      }
  	    else
*************** compute_branch_probabilities ()
*** 265,275 ****
  	    EDGE_INFO (e)->count_valid = 1;
  	    BB_INFO (bb)->succ_count--;
  	    BB_INFO (e->dest)->pred_count--;
  	  }
      }
  
    if (rtl_dump_file)
!     fprintf (rtl_dump_file, "%d edge counts read\n", num_edges);
  
    /* For every block in the file,
       - if every exit/entrance edge has a known count, then set the block count
--- 265,282 ----
  	    EDGE_INFO (e)->count_valid = 1;
  	    BB_INFO (bb)->succ_count--;
  	    BB_INFO (e->dest)->pred_count--;
+ 	    if (rtl_dump_file)
+ 	      {
+ 		fprintf (rtl_dump_file, "\nRead edge from %i to %i, count:",
+ 			 bb->index, e->dest->index);
+ 		fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC,
+ 			 (HOST_WIDEST_INT) e->count);
+ 	      }
  	  }
      }
  
    if (rtl_dump_file)
!     fprintf (rtl_dump_file, "\n%d edge counts read\n", num_edges);
  
    /* For every block in the file,
       - if every exit/entrance edge has a known count, then set the block count
*************** compute_branch_probabilities ()
*** 303,309 ****
  	      if (bi->succ_count == 0)
  		{
  		  edge e;
! 		  int total = 0;
  
  		  for (e = bb->succ; e; e = e->succ_next)
  		    total += e->count;
--- 310,316 ----
  	      if (bi->succ_count == 0)
  		{
  		  edge e;
! 		  gcov_type total = 0;
  
  		  for (e = bb->succ; e; e = e->succ_next)
  		    total += e->count;
*************** compute_branch_probabilities ()
*** 314,320 ****
  	      else if (bi->pred_count == 0)
  		{
  		  edge e;
! 		  int total = 0;
  
  		  for (e = bb->pred; e; e = e->pred_next)
  		    total += e->count;
--- 321,327 ----
  	      else if (bi->pred_count == 0)
  		{
  		  edge e;
! 		  gcov_type total = 0;
  
  		  for (e = bb->pred; e; e = e->pred_next)
  		    total += e->count;
*************** compute_branch_probabilities ()
*** 328,334 ****
  	      if (bi->succ_count == 1)
  		{
  		  edge e;
! 		  int total = 0;
  
  		  /* One of the counts will be invalid, but it is zero,
  		     so adding it in also doesn't hurt.  */
--- 335,341 ----
  	      if (bi->succ_count == 1)
  		{
  		  edge e;
! 		  gcov_type total = 0;
  
  		  /* One of the counts will be invalid, but it is zero,
  		     so adding it in also doesn't hurt.  */
*************** compute_branch_probabilities ()
*** 355,361 ****
  	      if (bi->pred_count == 1)
  		{
  		  edge e;
! 		  int total = 0;
  
  		  /* One of the counts will be invalid, but it is zero,
  		     so adding it in also doesn't hurt.  */
--- 362,368 ----
  	      if (bi->pred_count == 1)
  		{
  		  edge e;
! 		  gcov_type total = 0;
  
  		  /* One of the counts will be invalid, but it is zero,
  		     so adding it in also doesn't hurt.  */
*************** compute_branch_probabilities ()
*** 411,417 ****
        basic_block bb = BASIC_BLOCK (i);
        edge e;
        rtx insn;
!       int total;
        rtx note;
  
        total = bb->count;
--- 418,424 ----
        basic_block bb = BASIC_BLOCK (i);
        edge e;
        rtx insn;
!       gcov_type total;
        rtx note;
  
        total = bb->count;
*************** static rtx
*** 1036,1049 ****
  gen_edge_profiler (edgeno)
       int edgeno;
  {
!   enum machine_mode mode = mode_for_size (LONG_TYPE_SIZE, MODE_INT, 0);
    rtx mem_ref, tmp;
    rtx sequence;
  
    start_sequence ();
  
    tmp = force_reg (Pmode, profiler_label);
!   tmp = plus_constant (tmp, LONG_TYPE_SIZE / BITS_PER_UNIT * edgeno);
    mem_ref = validize_mem (gen_rtx_MEM (mode, tmp));
  
    tmp = expand_binop (mode, add_optab, mem_ref, const1_rtx,
--- 1043,1056 ----
  gen_edge_profiler (edgeno)
       int edgeno;
  {
!   enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
    rtx mem_ref, tmp;
    rtx sequence;
  
    start_sequence ();
  
    tmp = force_reg (Pmode, profiler_label);
!   tmp = plus_constant (tmp, GCOV_TYPE_SIZE / BITS_PER_UNIT * edgeno);
    mem_ref = validize_mem (gen_rtx_MEM (mode, tmp));
  
    tmp = expand_binop (mode, add_optab, mem_ref, const1_rtx,
*************** output_func_start_profiler ()
*** 1068,1074 ****
    char buf[20];
    const char *cfnname;
    rtx table_address;
!   enum machine_mode mode = mode_for_size (LONG_TYPE_SIZE, MODE_INT, 0);
    int save_flag_inline_functions = flag_inline_functions;
    int save_flag_test_coverage = flag_test_coverage;
    int save_profile_arc_flag = profile_arc_flag;
--- 1075,1081 ----
    char buf[20];
    const char *cfnname;
    rtx table_address;
!   enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
    int save_flag_inline_functions = flag_inline_functions;
    int save_flag_test_coverage = flag_test_coverage;
    int save_profile_arc_flag = profile_arc_flag;



More information about the Gcc-patches mailing list