diff options
author | Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> | 2003-06-26 09:52:10 +0200 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2003-06-26 07:52:10 +0000 |
commit | af166e5d276114872596002803f7c300fc41a511 (patch) | |
tree | 705173673c74024b0bd270eb542967036fde5a26 /gcc/libgcov.c | |
parent | ff25ef99762093b40198f4560cfd78a0e6e61ffb (diff) | |
download | gcc-af166e5d276114872596002803f7c300fc41a511.zip gcc-af166e5d276114872596002803f7c300fc41a511.tar.gz gcc-af166e5d276114872596002803f7c300fc41a511.tar.bz2 |
value-prof.c: New.
* value-prof.c: New.
* value-prof.h: New.
* Makefile.in (value-prof.o): New.
(LIBGCOV): Add _gcov_merge_single and _gcov_merge_delta
(profile.o): Add value-prof.h and tree.h dependency.
* flags.h (flag_profile_values): Declare.
* gcov-io.h (GCOV_COUNTERS, GCOV_COUNTER_NAMES, GCOV_MERGE_FUNCTIONS):
Add new counters.
(GCOV_COUNTER_V_INTERVAL, GCOV_COUNTER_V_POW2, GCOV_COUNTER_V_SINGLE,
GCOV_COUNTER_V_DELTA): New counter sections.
(__gcov_merge_single, __gcov_merge_delta): Declare.
* flow.c (mark_used_regs): Set subregs_of_mode only when the
structure is initialized.
* libgcov.c (__gcov_merge_single, __gcov_merge_delta): New functions.
* profile.c: Include value-prof.h and tree.h.
(gen_interval_profiler, gen_pow2_profiler, gen_one_value_profiler,
gen_const_delta_profiler, instrument_values): New static functions.
(get_exec_counts): Fix comment.
(branch_prob): Invoke instrument_values.
* toplev.c (flag_profile_values): New flag.
* doc/invoke.texi (-fprofile-values): Document.
From-SVN: r68519
Diffstat (limited to 'gcc/libgcov.c')
-rw-r--r-- | gcc/libgcov.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/gcc/libgcov.c b/gcc/libgcov.c index ba54281..5396c39 100644 --- a/gcc/libgcov.c +++ b/gcc/libgcov.c @@ -63,6 +63,16 @@ void __gcov_merge_add (gcov_type *counters __attribute__ ((unused)), unsigned n_counters __attribute__ ((unused))) {} #endif +#ifdef L_gcov_merge_single +void __gcov_merge_single (gcov_type *counters __attribute__ ((unused)), + unsigned n_counters __attribute__ ((unused))) {} +#endif + +#ifdef L_gcov_merge_delta +void __gcov_merge_delta (gcov_type *counters __attribute__ ((unused)), + unsigned n_counters __attribute__ ((unused))) {} +#endif + #else #include <string.h> @@ -466,4 +476,83 @@ __gcov_merge_add (gcov_type *counters, unsigned n_counters) } #endif /* L_gcov_merge_add */ +#ifdef L_gcov_merge_single +/* The profile merging function for choosing the most common value. It is given + an array COUNTERS of N_COUNTERS old counters and it reads the same number + of counters from the gcov file. The counters are split into 3-tuples + where the members of the tuple have meanings: + -- the stored candidate on the most common value of the measured entity + -- counter + -- total number of evaluations of the value */ +void +__gcov_merge_single (gcov_type *counters, unsigned n_counters) +{ + unsigned i, n_measures; + gcov_type value, counter, all; + + if (n_counters % 3) + abort (); + + n_measures = n_counters / 3; + for (i = 0; i < n_measures; i++, counters += 3) + { + value = gcov_read_counter (); + counter = gcov_read_counter (); + all = gcov_read_counter (); + + if (counters[0] == value) + counters[1] += counter; + else if (counter > counters[1]) + { + counters[0] = value; + counters[1] = counter - counters[1]; + } + else + counters[1] -= counter; + counters[2] += all; + } +} +#endif /* L_gcov_merge_single */ + +#ifdef L_gcov_merge_delta +/* The profile merging function for choosing the most common difference between + two consecutive evaluations of the value. It is given an array COUNTERS of + N_COUNTERS old counters and it reads the same number of counters from the + gcov file. The counters are split into 4-tuples where the members of the + tuple have meanings: + -- the last value of the measured entity + -- the stored candidate on the most common difference + -- counter + -- total number of evaluations of the value */ +void +__gcov_merge_delta (gcov_type *counters, unsigned n_counters) +{ + unsigned i, n_measures; + gcov_type last, value, counter, all; + + if (n_counters % 4) + abort (); + + n_measures = n_counters / 4; + for (i = 0; i < n_measures; i++, counters += 4) + { + last = gcov_read_counter (); + value = gcov_read_counter (); + counter = gcov_read_counter (); + all = gcov_read_counter (); + + if (counters[1] == value) + counters[2] += counter; + else if (counter > counters[2]) + { + counters[1] = value; + counters[2] = counter - counters[2]; + } + else + counters[2] -= counter; + counters[3] += all; + } +} +#endif /* L_gcov_merge_delta */ + #endif /* inhibit_libc */ |