From fc9161c19fe6c9301224cc856ea2d29561364e46 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Sat, 8 Mar 2008 20:52:50 +0000 Subject: coverage.h (tree_coverage_counter_addr): Declare. 2008-03-08 Richard Guenther * 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 --- gcc/coverage.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gcc/coverage.c') 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. */ -- cgit v1.1