aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorMartin Liska <marxin.liska@gmail.com>2013-11-11 23:21:02 +0000
committerMartin Liska <marxin@gcc.gnu.org>2013-11-11 23:21:02 +0000
commit86ce5d2fc19438f92afcba1273153071eab48da4 (patch)
tree91cab9d80f43cc346699b11a23a3f3458b7ab15e /libgcc
parent9544822809268ed981b10d31efd6225361ba537b (diff)
downloadgcc-86ce5d2fc19438f92afcba1273153071eab48da4.zip
gcc-86ce5d2fc19438f92afcba1273153071eab48da4.tar.gz
gcc-86ce5d2fc19438f92afcba1273153071eab48da4.tar.bz2
Time profiler introduced.
Co-Authored-By: Jan Hubicka <jh@suse.cz> From-SVN: r204690
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/Makefile.in2
-rw-r--r--libgcc/libgcov.c38
2 files changed, 39 insertions, 1 deletions
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index 354fb72..0d91cfc 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -858,7 +858,7 @@ LIBGCOV = _gcov _gcov_merge_add _gcov_merge_single _gcov_merge_delta \
_gcov_execv _gcov_execvp _gcov_execve _gcov_reset _gcov_dump \
_gcov_interval_profiler _gcov_pow2_profiler _gcov_one_value_profiler \
_gcov_indirect_call_profiler _gcov_average_profiler _gcov_ior_profiler \
- _gcov_merge_ior _gcov_indirect_call_profiler_v2
+ _gcov_merge_ior _gcov_time_profiler _gcov_indirect_call_profiler_v2 _gcov_merge_time_profile
libgcov-objects = $(patsubst %,%$(objext),$(LIBGCOV))
diff --git a/libgcc/libgcov.c b/libgcc/libgcov.c
index 3c39331..6450fd7 100644
--- a/libgcc/libgcov.c
+++ b/libgcc/libgcov.c
@@ -80,6 +80,7 @@ void __gcov_merge_delta (gcov_type *counters __attribute__ ((unused)),
#include <sys/stat.h>
#endif
+extern gcov_type function_counter ATTRIBUTE_HIDDEN;
extern void gcov_clear (void) ATTRIBUTE_HIDDEN;
extern void gcov_exit (void) ATTRIBUTE_HIDDEN;
extern int gcov_dump_complete ATTRIBUTE_HIDDEN;
@@ -350,6 +351,10 @@ gcov_compute_histogram (struct gcov_summary *sum)
}
}
+
+/* Counter for first visit of each function. */
+gcov_type function_counter;
+
/* Dump the coverage counts. We merge with existing counts when
possible, to avoid growing the .da files ad infinitum. We use this
program's checksum to make sure we only accumulate whole program
@@ -974,6 +979,27 @@ __gcov_merge_ior (gcov_type *counters, unsigned n_counters)
}
#endif
+/* Time profiles are merged so that minimum from all valid (greater than zero)
+ * is stored. There could be a fork that creates new counters. To have
+ * the profile stable, we chosen to pick the smallest function visit time. */
+
+#ifdef L_gcov_merge_time_profile
+void
+__gcov_merge_time_profile (gcov_type *counters, unsigned n_counters)
+{
+ unsigned int i;
+ gcov_type value;
+
+ for (i = 0; i < n_counters; i++)
+ {
+ value = gcov_read_counter ();
+
+ if (value && (!counters[i] || value < counters[i]))
+ counters[i] = value;
+ }
+}
+#endif /* L_gcov_merge_time_profile */
+
#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
@@ -1202,6 +1228,18 @@ __gcov_indirect_call_profiler_v2 (gcov_type value, void* cur_func)
}
#endif
+#ifdef L_gcov_time_profiler
+
+/* Sets corresponding COUNTERS if there is no value. */
+
+void
+__gcov_time_profiler (gcov_type* counters)
+{
+ if (!counters[0])
+ counters[0] = ++function_counter;
+}
+#endif
+
#ifdef L_gcov_average_profiler
/* Increase corresponding COUNTER by VALUE. FIXME: Perhaps we want
to saturate up. */