summaryrefslogtreecommitdiffstats
path: root/libgcc
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-11 23:21:02 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-11 23:21:02 +0000
commit38fe12e377baa6c8dfe5845687e7ed3d1daf0769 (patch)
tree91cab9d80f43cc346699b11a23a3f3458b7ab15e /libgcc
parent7ec6ec03e2dc34882d54168b08a50b482d640540 (diff)
downloadppe42-gcc-38fe12e377baa6c8dfe5845687e7ed3d1daf0769.tar.gz
ppe42-gcc-38fe12e377baa6c8dfe5845687e7ed3d1daf0769.zip
Time profiler introduced.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204690 138bc75d-0d04-0410-961f-82ee72b054a4
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 354fb72d984..0d91cfc2d91 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 3c39331e6ba..6450fd76548 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. */
OpenPOWER on IntegriCloud