This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] edge profiler considering liveness


Hi,

as described in:
http://gcc.gnu.org/ml/gcc/2004-10/msg00149.html

I need the edge profiler to take liveness data into account when adding profiling code.
In order to replace insert_insn_on_edge by safe_insert_insn_on_edge life analysis has
to be available. Therefore I've added a profiling hook for initializing which performs
life analysis for the rtl version and is currently empty for the tree version.

Bootstrapped without regressions on s390 and s390x.

What do you think about it?

Bye,

Andreas


2004-10-26  Andreas Krebbel  <krebbel1@de.ibm.com>

	* profile.c (branch_prob): Call to init_edge_profiler added.
	* rtl-profile.c (rtl_init_edge_profiler): New function.
	(rtl_gen_edge_profiler): Replaced call to insert_insn_on_edge with
	call to safe_insert_insn_on_edge.
	(rtl_profile_hooks): rtl_init_edge_profiler added.
	* tree-profile.c (tree_init_edge_profiler): New function.
	(tree_profile_hooks): tree_init_edge_profiler added.
	* value-prof.h (profile_hooks) init_edge_profiler prototype added.

Index: gcc/profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/profile.c,v
retrieving revision 1.149
diff -p -c -r1.149 profile.c
*** gcc/profile.c	29 Sep 2004 06:42:24 -0000	1.149
--- gcc/profile.c	25 Oct 2004 06:51:50 -0000
*************** branch_prob (void)
*** 1095,1101 ****
    if (profile_arc_flag
        && coverage_counter_alloc (GCOV_COUNTER_ARCS, num_instrumented))
      {
!       unsigned n_instrumented = instrument_edges (el);
  
        if (n_instrumented != num_instrumented)
  	abort ();
--- 1095,1105 ----
    if (profile_arc_flag
        && coverage_counter_alloc (GCOV_COUNTER_ARCS, num_instrumented))
      {
!       unsigned n_instrumented;
! 
!       profile_hooks->init_edge_profiler ();
! 
!       n_instrumented = instrument_edges (el);
  
        if (n_instrumented != num_instrumented)
  	abort ();
Index: gcc/rtl-profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl-profile.c,v
retrieving revision 2.2
diff -p -c -r2.2 rtl-profile.c
*** gcc/rtl-profile.c	1 Sep 2004 20:58:52 -0000	2.2
--- gcc/rtl-profile.c	25 Oct 2004 06:51:50 -0000
*************** Software Foundation, 59 Temple Place - S
*** 64,69 ****
--- 64,77 ----
  #include "tree.h"
  #include "ggc.h"
  
+ /* Do initialization work for the edge profiler.  */
+ 
+ static void
+ rtl_init_edge_profiler (void)
+ {
+   life_analysis (NULL, 0);
+ }
+ 
  /* Output instructions as RTL to increment the edge execution count.  */
  
  static void
*************** rtl_gen_edge_profiler (int edgeno, edge 
*** 85,91 ****
  
    sequence = get_insns ();
    end_sequence ();
!   insert_insn_on_edge (sequence, e);
    rebuild_jump_labels (e->insns.r);
  }
  
--- 93,99 ----
  
    sequence = get_insns ();
    end_sequence ();
!   safe_insert_insn_on_edge (sequence, e);
    rebuild_jump_labels (e->insns.r);
  }
  
*************** static FILE *rtl_profile_dump_file (void
*** 413,418 ****
--- 421,427 ----
  
  struct profile_hooks rtl_profile_hooks =
  {
+   rtl_init_edge_profiler,
    rtl_gen_edge_profiler,
    rtl_gen_interval_profiler,
    rtl_gen_pow2_profiler,
Index: gcc/tree-profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-profile.c,v
retrieving revision 2.6
diff -p -c -r2.6 tree-profile.c
*** gcc/tree-profile.c	25 Sep 2004 10:06:17 -0000	2.6
--- gcc/tree-profile.c	25 Oct 2004 06:51:50 -0000
*************** Software Foundation, 59 Temple Place - S
*** 69,74 ****
--- 69,80 ----
  #include "value-prof.h"
  
  
+ 
+ /* Do initialization work for the edge profiler.  */
+ 
+ static void
+ tree_init_edge_profiler (void) {}
+ 
  /* Output instructions as GIMPLE trees to increment the edge 
     execution count, and insert them on E.  We rely on 
     bsi_insert_on_edge to preserve the order.  */
*************** struct tree_opt_pass pass_tree_profile =
*** 195,200 ****
--- 201,207 ----
  
  struct profile_hooks tree_profile_hooks =
  {
+   tree_init_edge_profiler,      /* init_edge_profiler */
    tree_gen_edge_profiler,	/* gen_edge_profiler */
    tree_gen_interval_profiler,   /* gen_interval_profiler */
    tree_gen_pow2_profiler,       /* gen_pow2_profiler */
Index: gcc/value-prof.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/value-prof.h,v
retrieving revision 1.9
diff -p -c -r1.9 value-prof.h
*** gcc/value-prof.h	15 Oct 2004 14:47:12 -0000	1.9
--- gcc/value-prof.h	25 Oct 2004 06:51:50 -0000
*************** extern bool value_profile_transformation
*** 80,85 ****
--- 80,89 ----
  
  /* External declarations for edge-based profiling.  */
  struct profile_hooks {
+ 
+   /* Insert code to initialize edge profiler.  */
+   void (*init_edge_profiler) (void);
+ 
    /* Insert code to increment an edge count.  */
    void (*gen_edge_profiler) (int, edge);
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]