diff options
author | Richard Guenther <rguenther@suse.de> | 2008-03-08 20:52:50 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-03-08 20:52:50 +0000 |
commit | fc9161c19fe6c9301224cc856ea2d29561364e46 (patch) | |
tree | a11f8cead0a4695e09503341eb0a32f9c0b9d922 | |
parent | 892f6e652e935a3ea26713d709b7268dd38a5b2e (diff) | |
download | gcc-fc9161c19fe6c9301224cc856ea2d29561364e46.zip gcc-fc9161c19fe6c9301224cc856ea2d29561364e46.tar.gz gcc-fc9161c19fe6c9301224cc856ea2d29561364e46.tar.bz2 |
coverage.h (tree_coverage_counter_addr): Declare.
2008-03-08 Richard Guenther <rguenther@suse.de>
* coverage.h (tree_coverage_counter_addr): Declare.
* coverage.c (tree_coverage_counter_addr): New function.
* tree-profile.c (tree_gen_edge_profiler): Unshare counter
before using again.
(tree_gen_pow2_profiler): Use tree_coverage_counter_addr.
(tree_gen_one_value_profiler): Likewise.
(tree_gen_ic_profiler): Likewise.
(tree_gen_average_profiler): Likewise.
(tree_gen_ior_profiler): Likewise.
From-SVN: r133041
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/coverage.c | 17 | ||||
-rw-r--r-- | gcc/coverage.h | 2 | ||||
-rw-r--r-- | gcc/tree-profile.c | 27 |
4 files changed, 42 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c1a187c..d17a993 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,17 @@ 2008-03-08 Richard Guenther <rguenther@suse.de> + * coverage.h (tree_coverage_counter_addr): Declare. + * coverage.c (tree_coverage_counter_addr): New function. + * tree-profile.c (tree_gen_edge_profiler): Unshare counter + before using again. + (tree_gen_pow2_profiler): Use tree_coverage_counter_addr. + (tree_gen_one_value_profiler): Likewise. + (tree_gen_ic_profiler): Likewise. + (tree_gen_average_profiler): Likewise. + (tree_gen_ior_profiler): Likewise. + +2008-03-08 Richard Guenther <rguenther@suse.de> + * tree-ssa-sccvn.h (vn_binary_op_lookup): Remove. (vn_binary_op_insert): Likewise. (vn_unary_op_lookup): Likewise. diff --git a/gcc/coverage.c b/gcc/coverage.c index 10db9de..f3a0152 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -442,6 +442,23 @@ tree_coverage_counter_ref (unsigned counter, unsigned no) return build4 (ARRAY_REF, gcov_type_node, tree_ctr_tables[counter], build_int_cst (NULL_TREE, no), NULL, NULL); } + +/* Generate a tree to access the address of COUNTER NO. */ + +tree +tree_coverage_counter_addr (unsigned counter, unsigned no) +{ + tree gcov_type_node = get_gcov_type (); + + gcc_assert (no < fn_n_ctrs[counter] - fn_b_ctrs[counter]); + no += prg_n_ctrs[counter] + fn_b_ctrs[counter]; + + /* "no" here is an array index, scaled to bytes later. */ + return build_fold_addr_expr (build4 (ARRAY_REF, gcov_type_node, + tree_ctr_tables[counter], + build_int_cst (NULL_TREE, no), + NULL, NULL)); +} /* Generate a checksum for a string. CHKSUM is the current checksum. */ diff --git a/gcc/coverage.h b/gcc/coverage.h index 9fa25f1..bf9917d 100644 --- a/gcc/coverage.h +++ b/gcc/coverage.h @@ -38,6 +38,8 @@ extern int coverage_begin_output (void); extern int coverage_counter_alloc (unsigned /*counter*/, unsigned/*num*/); /* Use a counter from the most recent allocation. */ extern tree tree_coverage_counter_ref (unsigned /*counter*/, unsigned/*num*/); +/* Use a counter address from the most recent allocation. */ +extern tree tree_coverage_counter_addr (unsigned /*counter*/, unsigned/*num*/); /* Get all the counters for the current function. */ extern gcov_type *get_coverage_counts (unsigned /*counter*/, diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index 00fbd86..57c9f5c 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -181,7 +181,7 @@ tree_gen_edge_profiler (int edgeno, edge e) 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); + stmt3 = build_gimple_modify_stmt (unshare_expr (ref), gcov_type_tmp_var); bsi_insert_on_edge (e, stmt1); bsi_insert_on_edge (e, stmt2); bsi_insert_on_edge (e, stmt3); @@ -231,11 +231,10 @@ tree_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base) { tree stmt = value->hvalue.stmt; block_stmt_iterator bsi = bsi_for_stmt (stmt); - tree ref = tree_coverage_counter_ref (tag, base), ref_ptr; + tree ref_ptr = tree_coverage_counter_addr (tag, base); tree call, val; - ref_ptr = force_gimple_operand_bsi (&bsi, - build_addr (ref, current_function_decl), + ref_ptr = force_gimple_operand_bsi (&bsi, ref_ptr, true, NULL_TREE, true, BSI_SAME_STMT); val = prepare_instrumented_value (&bsi, value); call = build_call_expr (tree_pow2_profiler_fn, 2, ref_ptr, val); @@ -251,11 +250,10 @@ tree_gen_one_value_profiler (histogram_value value, unsigned tag, unsigned base) { tree stmt = value->hvalue.stmt; block_stmt_iterator bsi = bsi_for_stmt (stmt); - tree ref = tree_coverage_counter_ref (tag, base), ref_ptr; + tree ref_ptr = tree_coverage_counter_addr (tag, base); tree call, val; - ref_ptr = force_gimple_operand_bsi (&bsi, - build_addr (ref, current_function_decl), + ref_ptr = force_gimple_operand_bsi (&bsi, ref_ptr, true, NULL_TREE, true, BSI_SAME_STMT); val = prepare_instrumented_value (&bsi, value); call = build_call_expr (tree_one_value_profiler_fn, 2, ref_ptr, val); @@ -275,10 +273,9 @@ tree_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base) tree tmp1, stmt1, stmt2, stmt3; tree stmt = value->hvalue.stmt; block_stmt_iterator bsi = bsi_for_stmt (stmt); - tree ref = tree_coverage_counter_ref (tag, base), ref_ptr; + tree ref_ptr = tree_coverage_counter_addr (tag, base); - ref_ptr = force_gimple_operand_bsi (&bsi, - build_addr (ref, current_function_decl), + ref_ptr = force_gimple_operand_bsi (&bsi, ref_ptr, true, NULL_TREE, true, BSI_SAME_STMT); /* Insert code: @@ -367,11 +364,10 @@ tree_gen_average_profiler (histogram_value value, unsigned tag, unsigned base) { tree stmt = value->hvalue.stmt; block_stmt_iterator bsi = bsi_for_stmt (stmt); - tree ref = tree_coverage_counter_ref (tag, base), ref_ptr; + tree ref_ptr = tree_coverage_counter_addr (tag, base); tree call, val; - ref_ptr = force_gimple_operand_bsi (&bsi, - build_addr (ref, current_function_decl), + ref_ptr = force_gimple_operand_bsi (&bsi, ref_ptr, true, NULL_TREE, true, BSI_SAME_STMT); val = prepare_instrumented_value (&bsi, value); @@ -388,11 +384,10 @@ tree_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base) { tree stmt = value->hvalue.stmt; block_stmt_iterator bsi = bsi_for_stmt (stmt); - tree ref = tree_coverage_counter_ref (tag, base), ref_ptr; + tree ref_ptr = tree_coverage_counter_addr (tag, base); tree call, val; - ref_ptr = force_gimple_operand_bsi (&bsi, - build_addr (ref, current_function_decl), + ref_ptr = force_gimple_operand_bsi (&bsi, ref_ptr, true, NULL_TREE, true, BSI_SAME_STMT); val = prepare_instrumented_value (&bsi, value); call = build_call_expr (tree_ior_profiler_fn, 2, ref_ptr, val); |