diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-07 10:39:14 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-07 10:39:14 +0000 |
commit | f81207a71959aba2d49077f6925e5a29f72f6dd7 (patch) | |
tree | 827e576fefcb176c59daffe8692b445d427bee4d /gcc/tree-profile.c | |
parent | f912ce81dfb7e3a4d3f61150dda53b9d1c95f851 (diff) | |
download | gcc-f81207a71959aba2d49077f6925e5a29f72f6dd7.tar.gz |
2007-12-07 Richard Guenther <rguenther@suse.de>
* tree-profile.c (gcov_type_tmp_var): New global variable.
(tree_gen_edge_profiler): Use a single shared variable decl per
function for edge counter incrementing.
(tree_profiling): Re-set the shared variable.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130672 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-profile.c')
-rw-r--r-- | gcc/tree-profile.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index 0fe370e0abc..95c1136353b 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -48,6 +48,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" static GTY(()) tree gcov_type_node; +static GTY(()) tree gcov_type_tmp_var; static GTY(()) tree tree_interval_profiler_fn; static GTY(()) tree tree_pow2_profiler_fn; static GTY(()) tree tree_one_value_profiler_fn; @@ -168,15 +169,19 @@ tree_init_edge_profiler (void) static void tree_gen_edge_profiler (int edgeno, edge e) { - tree tmp1 = create_tmp_var (gcov_type_node, "PROF"); - tree tmp2 = create_tmp_var (gcov_type_node, "PROF"); - tree ref = tree_coverage_counter_ref (GCOV_COUNTER_ARCS, edgeno); - tree one = build_int_cst (gcov_type_node, 1); - tree stmt1 = build_gimple_modify_stmt (tmp1, ref); - tree stmt2 = build_gimple_modify_stmt (tmp2, - build2 (PLUS_EXPR, gcov_type_node, - tmp1, one)); - tree stmt3 = build_gimple_modify_stmt (ref, tmp2); + tree ref, one, stmt1, stmt2, stmt3; + + /* 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 = build_gimple_modify_stmt (gcov_type_tmp_var, ref); + stmt2 = build_gimple_modify_stmt (gcov_type_tmp_var, + build2 (PLUS_EXPR, gcov_type_node, + gcov_type_tmp_var, one)); + stmt3 = build_gimple_modify_stmt (ref, gcov_type_tmp_var); bsi_insert_on_edge (e, stmt1); bsi_insert_on_edge (e, stmt2); bsi_insert_on_edge (e, stmt3); @@ -417,6 +422,10 @@ tree_profiling (void) the gcov datastructure initializer. */ if (cgraph_state == CGRAPH_STATE_FINISHED) return 0; + + /* Re-set global shared temporary variable for edge-counters. */ + gcov_type_tmp_var = NULL_TREE; + branch_prob (); if (! flag_branch_probabilities |