aboutsummaryrefslogtreecommitdiff
path: root/gcc/profile.c
diff options
context:
space:
mode:
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>2003-07-30 21:23:34 +0200
committerZdenek Dvorak <rakdver@gcc.gnu.org>2003-07-30 19:23:34 +0000
commit6e885ee3ff4f358d7a7e84b8687f27a61101a25f (patch)
tree3736c245736a667b97a048cf693be5fe11ae12ef /gcc/profile.c
parentfd9b4d64fb349ebc9c6aa1fb7f44ce3b42614032 (diff)
downloadgcc-6e885ee3ff4f358d7a7e84b8687f27a61101a25f.zip
gcc-6e885ee3ff4f358d7a7e84b8687f27a61101a25f.tar.gz
gcc-6e885ee3ff4f358d7a7e84b8687f27a61101a25f.tar.bz2
combine.c (distribute_notes): Cancel REG_VALUE_PROFILE notes.
* combine.c (distribute_notes): Cancel REG_VALUE_PROFILE notes. * gcov-io.h (GCOV_FIRST_VALUE_COUNTER, GCOV_LAST_VALUE_COUNTER, GCOV_N_VALUE_COUNTERS): New. * profile.c (compute_value_histograms): New static function. (branch_prob): Read back the value histograms. * rtl.c (reg_note_name): Add name for REG_VALUE_PROFILE note. * rtl.h (enum reg_note): Add REG_VALUE_PROFILE note. * value-prof.c: Add comment on reading the profile. * value-prof.h (COUNTER_FOR_HIST_TYPE, HIST_TYPE_FOR_COUNTER): New. * doc/invoke.texi (-fprofile-values): Document behavior with -fbranch-probabilities. From-SVN: r69969
Diffstat (limited to 'gcc/profile.c')
-rw-r--r--gcc/profile.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/gcc/profile.c b/gcc/profile.c
index dd23628..37a5ecb 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -117,6 +117,7 @@ static rtx gen_const_delta_profiler (struct histogram_value *, unsigned,
static unsigned instrument_edges (struct edge_list *);
static void instrument_values (unsigned, struct histogram_value *);
static void compute_branch_probabilities (void);
+static void compute_value_histograms (unsigned, struct histogram_value *);
static gcov_type * get_exec_counts (void);
static basic_block find_group (basic_block);
static void union_groups (basic_block, basic_block);
@@ -601,6 +602,57 @@ compute_branch_probabilities (void)
free_aux_for_blocks ();
}
+/* Load value histograms for N_VALUES values whose description is stored
+ in VALUES array from .da file. */
+static void
+compute_value_histograms (unsigned n_values, struct histogram_value *values)
+{
+ unsigned i, j, t, any;
+ unsigned n_histogram_counters[GCOV_N_VALUE_COUNTERS];
+ gcov_type *histogram_counts[GCOV_N_VALUE_COUNTERS];
+ gcov_type *act_count[GCOV_N_VALUE_COUNTERS];
+ gcov_type *aact_count;
+
+ for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++)
+ n_histogram_counters[t] = 0;
+
+ for (i = 0; i < n_values; i++)
+ n_histogram_counters[(int) (values[i].type)] += values[i].n_counters;
+
+ any = 0;
+ for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++)
+ {
+ histogram_counts[t] =
+ get_coverage_counts (COUNTER_FOR_HIST_TYPE (t),
+ n_histogram_counters[t], &profile_info);
+ if (histogram_counts[t])
+ any = 1;
+ act_count[t] = histogram_counts[t];
+ }
+ if (!any)
+ return;
+
+ for (i = 0; i < n_values; i++)
+ {
+ rtx hist_list = NULL_RTX;
+ t = (int) (values[i].type);
+
+ aact_count = act_count[t];
+ act_count[t] += values[i].n_counters;
+ for (j = values[i].n_counters; j > 0; j--)
+ hist_list = alloc_EXPR_LIST (0, GEN_INT (aact_count[j - 1]), hist_list);
+ hist_list = alloc_EXPR_LIST (0, copy_rtx (values[i].value), hist_list);
+ hist_list = alloc_EXPR_LIST (0, GEN_INT (values[i].type), hist_list);
+ REG_NOTES (values[i].insn) =
+ alloc_EXPR_LIST (REG_VALUE_PROFILE, hist_list,
+ REG_NOTES (values[i].insn));
+ }
+
+ for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++)
+ if (histogram_counts[t])
+ free (histogram_counts[t]);
+}
+
/* Instrument and/or analyze program behavior based on program flow graph.
In either case, this function builds a flow graph for the function being
compiled. The flow graph is stored in BB_GRAPH.
@@ -886,7 +938,11 @@ branch_prob (void)
}
if (flag_branch_probabilities)
- compute_branch_probabilities ();
+ {
+ compute_branch_probabilities ();
+ if (flag_profile_values)
+ compute_value_histograms (n_values, values);
+ }
/* For each edge not on the spanning tree, add counting code as rtl. */
if (profile_arc_flag