This is the mail archive of the gcc@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]

Re: conditional gcov instrumentation


Reattaching patch if not received.

--- gcc-4.4.0/gcc/tree-profile.c	2009-09-03 00:10:48.000000000 -0400
+++ gcc-4.4.0-gcov-ptr-src/gcc/tree-profile.c	2009-09-03
00:11:01.000000000 -0400
@@ -183,22 +183,25 @@
 static void
 tree_gen_edge_profiler (int edgeno, edge e)
 {
-  tree ref, one;
-  gimple stmt1, stmt2, stmt3;
+  tree ref;
+  gimple call;
+  tree decl, gcov_ctr_fn_type, ctr_ptr, gcov_type_ptr;

   /* We share one temporary variable declaration per function.  This
      gets re-set in tree_profiling.  */
   if (gcov_type_tmp_var == NULL_TREE)
     gcov_type_tmp_var = create_tmp_var (gcov_type_node, "PROF_edge_counter");
   ref = tree_coverage_counter_ref (GCOV_COUNTER_ARCS, edgeno);
-  one = build_int_cst (gcov_type_node, 1);
-  stmt1 = gimple_build_assign (gcov_type_tmp_var, ref);
-  stmt2 = gimple_build_assign_with_ops (PLUS_EXPR, gcov_type_tmp_var,
-					gcov_type_tmp_var, one);
-  stmt3 = gimple_build_assign (unshare_expr (ref), gcov_type_tmp_var);
-  gsi_insert_on_edge (e, stmt1);
-  gsi_insert_on_edge (e, stmt2);
-  gsi_insert_on_edge (e, stmt3);
+  gcov_type_ptr = build_pointer_type (get_gcov_type());
+
+  gcov_ctr_fn_type = build_function_type_list(void_type_node,
gcov_type_ptr, NULL_TREE);
+
+  decl = build_decl(FUNCTION_DECL, get_identifier("__gcov_ctr"),
gcov_ctr_fn_type);
+  ctr_ptr = build_addr(ref, current_function_decl);
+
+  call = gimple_build_call (decl, 1, ctr_ptr);
+
+  gsi_insert_on_edge (e, call);
 }

 /* Emits code to get VALUE to instrument at GSI, and returns the



On Mon, Sep 7, 2009 at 3:51 PM, Hayawardh V<hayawardh@gmail.com> wrote:
> Hi,
> I have been working on a conditional gcov patch, that calls a function
> everytime the gcov counter is to be modified, so the function can
> decide how to increment the counter.
> The function's prototype is :
>
> void __gcov_ctr(gcov_type*) ;
>
> where gcov_type would be, for example, long long depending on the architecture.
>
> This would be useful for kernel coverage instrumentation (eg) tracking
> the coverage of only a particular pid, or for implementing atomic
> counters per cpu, and probably for many others.
> The libgcov could have a weak default implementation which increments
> the counter by 1 as usual, and those wanting to add their own
> implementation could do so. (Suggested by Peter Oberparleiter).
>
> I am attaching a patch. Please comment.
>
> Regards,
> Hayawardh
>


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