[PATCH] Add support for profile merging hooks

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Tue Apr 22 19:24:00 GMT 2003


Hello,

some of the rtlopt profiling features require other info in addition
to counters be stored in .da file. Merging this extra information by
summing it clearly is not the right thing to do, so we added a support
for section specific merging functions.

Zdenek

	* gcov-io.h (merger_function, profile_merger_for_tag): Declare.
	* gcov-io.c (profile_merger_for_tag): New.
	* libgcov.c (gcov_exit): Use it.

Index: gcov-io.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/gcov-io.c,v
retrieving revision 1.1
diff -c -3 -p -r1.1 gcov-io.c
*** gcov-io.c	21 Apr 2003 19:48:09 -0000	1.1
--- gcov-io.c	22 Apr 2003 19:12:03 -0000
*************** gcov_read_summary (struct gcov_summary *
*** 414,419 ****
--- 414,429 ----
    summary->arc_sum_max = gcov_read_counter ();
  }
  
+ GCOV_LINKAGE merger_function
+ profile_merger_for_tag (tag)
+      unsigned tag;
+ {
+   switch (tag)
+     {
+     default:
+       return 0;
+     }
+ }
  
  #if IN_GCOV > 0
  /* Return the modification time of the current gcov file.  */
Index: gcov-io.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/gcov-io.h,v
retrieving revision 1.28
diff -c -3 -p -r1.28 gcov-io.h
*** gcov-io.h	22 Apr 2003 17:21:04 -0000	1.28
--- gcov-io.h	22 Apr 2003 19:12:04 -0000
*************** static int gcov_is_error (void);
*** 341,346 ****
--- 341,349 ----
  GCOV_LINKAGE time_t gcov_time (void);
  #endif
  
+ typedef int (*merger_function) PARAMS ((gcov_type *, unsigned));
+ GCOV_LINKAGE merger_function profile_merger_for_tag PARAMS ((unsigned));
+ 
  /* Save the current position in the gcov file.  */
  
  static inline unsigned long
Index: libgcov.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/libgcov.c,v
retrieving revision 1.8
diff -c -3 -p -r1.8 libgcov.c
*** libgcov.c	21 Apr 2003 19:48:10 -0000	1.8
--- libgcov.c	22 Apr 2003 19:12:04 -0000
*************** gcov_exit (void)
*** 101,106 ****
--- 101,107 ----
    gcov_type program_max_one = 0;
    gcov_type program_sum = 0;
    unsigned program_arcs = 0;
+   merger_function merger;
    struct gcov_summary last_prg;
    
    last_prg.runs = 0;
*************** gcov_exit (void)
*** 248,255 ****
  		  if (n_counters != length / 8)
  		    goto read_mismatch;
  		 
! 		  for (jx = 0; jx < n_counters; jx++)
! 		    counters[sect_index][jx] += gcov_read_counter ();
  		  
  		  counters[sect_index] += n_counters;
  		}
--- 249,264 ----
  		  if (n_counters != length / 8)
  		    goto read_mismatch;
  		 
! 		  if ((merger = profile_merger_for_tag (tag)))
! 		    {
! 		      if ((*merger) (counters[sect_index], n_counters))
! 			goto read_error;
! 		    }
! 		  else
! 		    {
! 		      for (jx = 0; jx < n_counters; jx++)
! 			counters[sect_index][jx] += gcov_read_counter ();
! 		    }
  		  
  		  counters[sect_index] += n_counters;
  		}



More information about the Gcc-patches mailing list