Commit af166e5d by Zdenek Dvorak Committed by Zdenek Dvorak

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
parent ff25ef99
2003-06-24 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> 2003-06-26 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* 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.
2003-06-26 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* Makefile.in (cfgrtl.o): Add expr.h dependency. * Makefile.in (cfgrtl.o): Add expr.h dependency.
* cfgrtl.c: Include expr.h. * cfgrtl.c: Include expr.h.
......
...@@ -814,7 +814,7 @@ OBJS = alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \ ...@@ -814,7 +814,7 @@ OBJS = alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o \
insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o \ insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o \
integrate.o intl.o jump.o langhooks.o lcm.o lists.o local-alloc.o \ integrate.o intl.o jump.o langhooks.o lcm.o lists.o local-alloc.o \
loop.o mbchar.o optabs.o options.o opts.o params.o predict.o \ loop.o mbchar.o optabs.o options.o opts.o params.o predict.o \
print-rtl.o print-tree.o \ print-rtl.o print-tree.o value-prof.o \
profile.o ra.o ra-build.o ra-colorize.o ra-debug.o ra-rewrite.o \ profile.o ra.o ra-build.o ra-colorize.o ra-debug.o ra-rewrite.o \
real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \ real.o recog.o reg-stack.o regclass.o regmove.o regrename.o \
reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \ reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o \
...@@ -854,7 +854,7 @@ STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \ ...@@ -854,7 +854,7 @@ STAGESTUFF = *$(objext) insn-flags.h insn-config.h insn-codes.h \
LIB2FUNCS_ST = _eprintf __gcc_bcmp LIB2FUNCS_ST = _eprintf __gcc_bcmp
# Defined in libgcov.c, included only in gcov library # Defined in libgcov.c, included only in gcov library
LIBGCOV = _gcov _gcov_merge_add LIBGCOV = _gcov _gcov_merge_add _gcov_merge_single _gcov_merge_delta
FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \ FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
_fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \ _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
...@@ -1636,7 +1636,10 @@ conflict.o : conflict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(OBSTACK_H) ...@@ -1636,7 +1636,10 @@ conflict.o : conflict.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(OBSTACK_H)
$(HASHTAB_H) $(RTL_H) hard-reg-set.h $(BASIC_BLOCK_H) $(HASHTAB_H) $(RTL_H) hard-reg-set.h $(BASIC_BLOCK_H)
profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \ profile.o : profile.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(TREE_H) flags.h output.h $(REGS_H) $(EXPR_H) function.h \ $(TREE_H) flags.h output.h $(REGS_H) $(EXPR_H) function.h \
toplev.h $(BASIC_BLOCK_H) $(COVERAGE_H) toplev.h $(BASIC_BLOCK_H) $(COVERAGE_H) $(TREE_H) value-prof.h
value-prof.o : value-prof.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
$(BASIC_BLOCK_H) hard-reg-set.h value-prof.h $(EXPR_H) output.h flags.h \
$(RECOG_H) insn-config.h $(OPTABS_H)
loop.o : loop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h $(LOOP_H) \ loop.o : loop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h $(LOOP_H) \
insn-config.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) \ insn-config.h $(REGS_H) hard-reg-set.h $(RECOG_H) $(EXPR_H) \
real.h $(PREDICT_H) $(BASIC_BLOCK_H) function.h cfgloop.h \ real.h $(PREDICT_H) $(BASIC_BLOCK_H) function.h cfgloop.h \
......
...@@ -191,6 +191,10 @@ extern int profile_flag; ...@@ -191,6 +191,10 @@ extern int profile_flag;
extern int profile_arc_flag; extern int profile_arc_flag;
/* Nonzero if value profile should be measured. */
extern int flag_profile_values;
/* Nonzero if generating info for gcov to calculate line test coverage. */ /* Nonzero if generating info for gcov to calculate line test coverage. */
extern int flag_test_coverage; extern int flag_test_coverage;
......
...@@ -3842,7 +3842,8 @@ mark_used_regs (pbi, x, cond, insn) ...@@ -3842,7 +3842,8 @@ mark_used_regs (pbi, x, cond, insn)
case SUBREG: case SUBREG:
#ifdef CANNOT_CHANGE_MODE_CLASS #ifdef CANNOT_CHANGE_MODE_CLASS
if (GET_CODE (SUBREG_REG (x)) == REG if ((flags & PROP_REG_INFO)
&& GET_CODE (SUBREG_REG (x)) == REG
&& REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER) && REGNO (SUBREG_REG (x)) >= FIRST_PSEUDO_REGISTER)
bitmap_set_bit (&subregs_of_mode, REGNO (SUBREG_REG (x)) bitmap_set_bit (&subregs_of_mode, REGNO (SUBREG_REG (x))
* MAX_MACHINE_MODE * MAX_MACHINE_MODE
...@@ -3891,7 +3892,8 @@ mark_used_regs (pbi, x, cond, insn) ...@@ -3891,7 +3892,8 @@ mark_used_regs (pbi, x, cond, insn)
|| GET_CODE (testreg) == SUBREG) || GET_CODE (testreg) == SUBREG)
{ {
#ifdef CANNOT_CHANGE_MODE_CLASS #ifdef CANNOT_CHANGE_MODE_CLASS
if (GET_CODE (testreg) == SUBREG if ((flags & PROP_REG_INFO)
&& GET_CODE (testreg) == SUBREG
&& GET_CODE (SUBREG_REG (testreg)) == REG && GET_CODE (SUBREG_REG (testreg)) == REG
&& REGNO (SUBREG_REG (testreg)) >= FIRST_PSEUDO_REGISTER) && REGNO (SUBREG_REG (testreg)) >= FIRST_PSEUDO_REGISTER)
bitmap_set_bit (&subregs_of_mode, REGNO (SUBREG_REG (testreg)) bitmap_set_bit (&subregs_of_mode, REGNO (SUBREG_REG (testreg))
......
...@@ -269,14 +269,24 @@ typedef HOST_WIDEST_INT gcov_type; ...@@ -269,14 +269,24 @@ typedef HOST_WIDEST_INT gcov_type;
#define GCOV_COUNTER_ARCS 0 /* Arc transitions. */ #define GCOV_COUNTER_ARCS 0 /* Arc transitions. */
#define GCOV_COUNTERS_SUMMABLE 1 /* Counters which can be #define GCOV_COUNTERS_SUMMABLE 1 /* Counters which can be
summaried. */ summaried. */
#define GCOV_COUNTERS 1 #define GCOV_COUNTER_V_INTERVAL 1 /* Histogram of value inside an interval. */
#define GCOV_COUNTER_V_POW2 2 /* Histogram of exact power2 logarithm
/* A list of human readable names of the counters */ of a value. */
#define GCOV_COUNTER_NAMES {"arcs"} #define GCOV_COUNTER_V_SINGLE 3 /* The most common value of expression. */
#define GCOV_COUNTER_V_DELTA 4 /* The most common difference between
/* Names of merge functions for counters. */ consecutive values of expression. */
#define GCOV_MERGE_FUNCTIONS {"__gcov_merge_add"} #define GCOV_COUNTERS 5
/* A list of human readable names of the counters */
#define GCOV_COUNTER_NAMES {"arcs", "interval", "pow2", "single", "delta"}
/* Names of merge functions for counters. */
#define GCOV_MERGE_FUNCTIONS {"__gcov_merge_add", \
"__gcov_merge_add", \
"__gcov_merge_add", \
"__gcov_merge_single", \
"__gcov_merge_delta"}
/* Convert a counter index to a tag. */ /* Convert a counter index to a tag. */
#define GCOV_TAG_FOR_COUNTER(COUNT) \ #define GCOV_TAG_FOR_COUNTER(COUNT) \
(GCOV_TAG_COUNTER_BASE + ((gcov_unsigned_t)(COUNT) << 17)) (GCOV_TAG_COUNTER_BASE + ((gcov_unsigned_t)(COUNT) << 17))
...@@ -380,6 +390,13 @@ extern void __gcov_flush (void); ...@@ -380,6 +390,13 @@ extern void __gcov_flush (void);
/* The merge function that just sums the counters. */ /* The merge function that just sums the counters. */
extern void __gcov_merge_add (gcov_type *, unsigned); extern void __gcov_merge_add (gcov_type *, unsigned);
/* The merge function to choose the most often value. */
extern void __gcov_merge_single (gcov_type *, unsigned);
/* The merge function to choose the most often difference between consecutive
values. */
extern void __gcov_merge_delta (gcov_type *, unsigned);
#endif /* IN_LIBGCOV */ #endif /* IN_LIBGCOV */
#if IN_LIBGCOV >= 0 #if IN_LIBGCOV >= 0
......
...@@ -63,6 +63,16 @@ void __gcov_merge_add (gcov_type *counters __attribute__ ((unused)), ...@@ -63,6 +63,16 @@ void __gcov_merge_add (gcov_type *counters __attribute__ ((unused)),
unsigned n_counters __attribute__ ((unused))) {} unsigned n_counters __attribute__ ((unused))) {}
#endif #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 #else
#include <string.h> #include <string.h>
...@@ -466,4 +476,83 @@ __gcov_merge_add (gcov_type *counters, unsigned n_counters) ...@@ -466,4 +476,83 @@ __gcov_merge_add (gcov_type *counters, unsigned n_counters)
} }
#endif /* L_gcov_merge_add */ #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 */ #endif /* inhibit_libc */
...@@ -410,6 +410,10 @@ int profile_flag = 0; ...@@ -410,6 +410,10 @@ int profile_flag = 0;
int profile_arc_flag = 0; int profile_arc_flag = 0;
/* Nonzero if value histograms should be measured. */
int flag_profile_values = 0;
/* Nonzero if generating info for gcov to calculate line test coverage. */ /* Nonzero if generating info for gcov to calculate line test coverage. */
int flag_test_coverage = 0; int flag_test_coverage = 0;
...@@ -1184,6 +1188,8 @@ static const lang_independent_options f_options[] = ...@@ -1184,6 +1188,8 @@ static const lang_independent_options f_options[] =
N_("Create data files needed by gcov") }, N_("Create data files needed by gcov") },
{"branch-probabilities", &flag_dummy, 1, {"branch-probabilities", &flag_dummy, 1,
N_("Use profiling information for branch probabilities") }, N_("Use profiling information for branch probabilities") },
{"profile-values", &flag_profile_values, 1,
N_("Insert code to profile values of expressions") },
{"profile", &flag_dummy, 1, {"profile", &flag_dummy, 1,
N_("Enable basic program profiling code") }, N_("Enable basic program profiling code") },
{"reorder-blocks", &flag_dummy, 1, {"reorder-blocks", &flag_dummy, 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment