summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2010-12-21 22:58:57 +0000
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>2010-12-21 22:58:57 +0000
commitfc49fbc1a1a157818bc3d4381c5d6a71a0674a36 (patch)
tree457d8f8e6a793fbec8f9604b394a356b9b984701 /gcc
parentab1689b1a071703f2e7a8c36cf512446a973d7be (diff)
downloadgcc-fc49fbc1a1a157818bc3d4381c5d6a71a0674a36.tar.gz
* value-prof.c (value_prof_hooks): Remove.
(struct value_prof_hooks): Remove. (gimple_value_prof_hooks): Remove. (gimple_register_value_prof_hooks): Remove. (find_values_to_profile): Remove. (value_profile_transformations): Remove. (gimple_value_profile_transformations): No longer static. (gimple_find_values_to_profile): Likewise. * value-prof.h (gimple_register_value_prof_hooks): Remove prototype. (find_values_to_profile): Likewise. (value_profile_transformations): Likewise. (tree_register_profile_hooks): Likewise. (struct profile_hooks): Remove. (tree_profile_hooks): Remove. (gimple_find_values_to_profile): New protoype. (gimple_value_profile_transformations): Likewise. (gimple_init_edge_profiler): Likewise. (gimple_gen_edge_profiler): Likewise. (gimple_gen_interval_profiler): Likewise. (gimple_gen_pow2_profiler): Likewise. (gimple_gen_one_value_profiler): Likewise. (gimple_gen_ic_profiler): Likewise. (gimple_gen_ic_func_profiler): Likewise. (gimple_gen_const_delta_profiler): Likewise. (gimple_gen_average_profiler): Likewise. (gimple_gen_ior_profiler): Likewise. * profile.c (profile_hooks): Remove. (instrument_edges): Call profiling functions directly instead of through removed profile_hooks. (instrument_values): Likewise. (branch_prob): Call gimple_find_values_to_profile instead of removed find_values_to_profile. Call gimple_init_edge_profiler instead of removed hook. (tree_register_profile_hooks): Remove. * tree-profile.c (tree_init_ic_make_global_vars): Rename to init_ic_make_global_vars. (tree_init_edge_profiler): Rename to gimple_init_edge_profiler and no longer static. (tree_gen_edge_profiler, tree_gen_interval_profiler, tree_gen_pow2_profiler, tree_gen_one_value_profiler, tree_gen_ic_profiler, tree_gen_ic_func_profiler, tree_gen_const_delta_profiler, tree_gen_average_profiler, tree_gen_ior_profiler): Similarly renamed and no longer static. (tree_profiling): Do not initialize tree profiling hooks. (tree_profile_hooks): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@168141 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog49
-rw-r--r--gcc/profile.c31
-rw-r--r--gcc/tree-profile.c67
-rw-r--r--gcc/value-prof.c39
-rw-r--r--gcc/value-prof.h58
5 files changed, 102 insertions, 142 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 133b65bbf0b..6f61a6bffaa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,52 @@
+2010-12-21 Steven Bosscher <steven@gcc.gnu.org>
+
+ De-hookize profile infrastructure.
+ * value-prof.c (value_prof_hooks): Remove.
+ (struct value_prof_hooks): Remove.
+ (gimple_value_prof_hooks): Remove.
+ (gimple_register_value_prof_hooks): Remove.
+ (find_values_to_profile): Remove.
+ (value_profile_transformations): Remove.
+ (gimple_value_profile_transformations): No longer static.
+ (gimple_find_values_to_profile): Likewise.
+ * value-prof.h (gimple_register_value_prof_hooks): Remove prototype.
+ (find_values_to_profile): Likewise.
+ (value_profile_transformations): Likewise.
+ (tree_register_profile_hooks): Likewise.
+ (struct profile_hooks): Remove.
+ (tree_profile_hooks): Remove.
+ (gimple_find_values_to_profile): New protoype.
+ (gimple_value_profile_transformations): Likewise.
+ (gimple_init_edge_profiler): Likewise.
+ (gimple_gen_edge_profiler): Likewise.
+ (gimple_gen_interval_profiler): Likewise.
+ (gimple_gen_pow2_profiler): Likewise.
+ (gimple_gen_one_value_profiler): Likewise.
+ (gimple_gen_ic_profiler): Likewise.
+ (gimple_gen_ic_func_profiler): Likewise.
+ (gimple_gen_const_delta_profiler): Likewise.
+ (gimple_gen_average_profiler): Likewise.
+ (gimple_gen_ior_profiler): Likewise.
+ * profile.c (profile_hooks): Remove.
+ (instrument_edges): Call profiling functions directly instead
+ of through removed profile_hooks.
+ (instrument_values): Likewise.
+ (branch_prob): Call gimple_find_values_to_profile instead of
+ removed find_values_to_profile.
+ Call gimple_init_edge_profiler instead of removed hook.
+ (tree_register_profile_hooks): Remove.
+ * tree-profile.c (tree_init_ic_make_global_vars): Rename to
+ init_ic_make_global_vars.
+ (tree_init_edge_profiler): Rename to gimple_init_edge_profiler
+ and no longer static.
+ (tree_gen_edge_profiler, tree_gen_interval_profiler,
+ tree_gen_pow2_profiler, tree_gen_one_value_profiler,
+ tree_gen_ic_profiler, tree_gen_ic_func_profiler,
+ tree_gen_const_delta_profiler, tree_gen_average_profiler,
+ tree_gen_ior_profiler): Similarly renamed and no longer static.
+ (tree_profiling): Do not initialize tree profiling hooks.
+ (tree_profile_hooks): Remove.
+
2010-12-21 Jakub Jelinek <jakub@redhat.com>
PR target/46880
diff --git a/gcc/profile.c b/gcc/profile.c
index 606e3b2e866..bde8b4677f9 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -72,9 +72,6 @@ along with GCC; see the file COPYING3. If not see
#include "profile.h"
-/* Hooks for profiling. */
-static struct profile_hooks* profile_hooks;
-
struct bb_info {
unsigned int count_valid : 1;
@@ -141,7 +138,7 @@ instrument_edges (struct edge_list *el)
fprintf (dump_file, "Edge %d to %d instrumented%s\n",
e->src->index, e->dest->index,
EDGE_CRITICAL_P (e) ? " (and split)" : "");
- (profile_hooks->gen_edge_profiler) (num_instr_edges++, e);
+ gimple_gen_edge_profiler (num_instr_edges++, e);
}
}
}
@@ -202,31 +199,31 @@ instrument_values (histogram_values values)
switch (hist->type)
{
case HIST_TYPE_INTERVAL:
- (profile_hooks->gen_interval_profiler) (hist, t, 0);
+ gimple_gen_interval_profiler (hist, t, 0);
break;
case HIST_TYPE_POW2:
- (profile_hooks->gen_pow2_profiler) (hist, t, 0);
+ gimple_gen_pow2_profiler (hist, t, 0);
break;
case HIST_TYPE_SINGLE_VALUE:
- (profile_hooks->gen_one_value_profiler) (hist, t, 0);
+ gimple_gen_one_value_profiler (hist, t, 0);
break;
case HIST_TYPE_CONST_DELTA:
- (profile_hooks->gen_const_delta_profiler) (hist, t, 0);
+ gimple_gen_const_delta_profiler (hist, t, 0);
break;
case HIST_TYPE_INDIR_CALL:
- (profile_hooks->gen_ic_profiler) (hist, t, 0);
+ gimple_gen_ic_profiler (hist, t, 0);
break;
case HIST_TYPE_AVERAGE:
- (profile_hooks->gen_average_profiler) (hist, t, 0);
+ gimple_gen_average_profiler (hist, t, 0);
break;
case HIST_TYPE_IOR:
- (profile_hooks->gen_ior_profiler) (hist, t, 0);
+ gimple_gen_ior_profiler (hist, t, 0);
break;
default:
@@ -1170,7 +1167,7 @@ branch_prob (void)
#undef BB_TO_GCOV_INDEX
if (flag_profile_values)
- find_values_to_profile (&values);
+ gimple_find_values_to_profile (&values);
if (flag_branch_probabilities)
{
@@ -1187,7 +1184,7 @@ branch_prob (void)
{
unsigned n_instrumented;
- profile_hooks->init_edge_profiler ();
+ gimple_init_edge_profiler ();
n_instrumented = instrument_edges (el);
@@ -1372,11 +1369,3 @@ end_branch_prob (void)
}
}
-/* Set up hooks to enable tree-based profiling. */
-
-void
-tree_register_profile_hooks (void)
-{
- gcc_assert (current_ir_type () == IR_GIMPLE);
- profile_hooks = &tree_profile_hooks;
-}
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index c5cfa422f0b..c1c0577c2ef 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -65,7 +65,7 @@ static GTY(()) tree ptr_void;
static void* __gcov_indirect_call_callee; // actual callee address
*/
static void
-tree_init_ic_make_global_vars (void)
+init_ic_make_global_vars (void)
{
tree gcov_type_ptr;
@@ -95,8 +95,8 @@ tree_init_ic_make_global_vars (void)
varpool_mark_needed_node (varpool_node (ic_gcov_type_ptr_var));
}
-static void
-tree_init_edge_profiler (void)
+void
+gimple_init_edge_profiler (void)
{
tree interval_profiler_fn_type;
tree pow2_profiler_fn_type;
@@ -149,7 +149,7 @@ tree_init_edge_profiler (void)
= tree_cons (get_identifier ("leaf"), NULL,
DECL_ATTRIBUTES (tree_one_value_profiler_fn));
- tree_init_ic_make_global_vars ();
+ init_ic_make_global_vars ();
/* void (*) (gcov_type *, gcov_type, void *, void *) */
ic_profiler_fn_type
@@ -199,8 +199,8 @@ tree_init_edge_profiler (void)
execution count, and insert them on E. We rely on
gsi_insert_on_edge to preserve the order. */
-static void
-tree_gen_edge_profiler (int edgeno, edge e)
+void
+gimple_gen_edge_profiler (int edgeno, edge e)
{
tree ref, one;
gimple stmt1, stmt2, stmt3;
@@ -239,8 +239,8 @@ prepare_instrumented_value (gimple_stmt_iterator *gsi, histogram_value value)
counter. VALUE is the expression whose value is profiled. TAG is the
tag of the section for counters, BASE is offset of the counter position. */
-static void
-tree_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base)
+void
+gimple_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base)
{
gimple stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
@@ -265,8 +265,8 @@ tree_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base)
counter. VALUE is the expression whose value is profiled. TAG is the tag
of the section for counters, BASE is offset of the counter position. */
-static void
-tree_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
+void
+gimple_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
{
gimple stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
@@ -285,8 +285,8 @@ tree_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
VALUE is the expression whose value is profiled. TAG is the tag of the
section for counters, BASE is offset of the counter position. */
-static void
-tree_gen_one_value_profiler (histogram_value value, unsigned tag, unsigned base)
+void
+gimple_gen_one_value_profiler (histogram_value value, unsigned tag, unsigned base)
{
gimple stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
@@ -308,8 +308,8 @@ tree_gen_one_value_profiler (histogram_value value, unsigned tag, unsigned base)
TAG is the tag of the section for counters, BASE is offset of the
counter position. */
-static void
-tree_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base)
+void
+gimple_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base)
{
tree tmp1;
gimple stmt1, stmt2, stmt3;
@@ -343,8 +343,8 @@ tree_gen_ic_profiler (histogram_value value, unsigned tag, unsigned base)
beginning of every possible called function.
*/
-static void
-tree_gen_ic_func_profiler (void)
+void
+gimple_gen_ic_func_profiler (void)
{
struct cgraph_node * c_node = cgraph_node (current_function_decl);
gimple_stmt_iterator gsi;
@@ -354,7 +354,7 @@ tree_gen_ic_func_profiler (void)
if (cgraph_only_called_directly_p (c_node))
return;
- tree_init_edge_profiler ();
+ gimple_init_edge_profiler ();
gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR));
@@ -387,8 +387,8 @@ tree_gen_ic_func_profiler (void)
VALUE is the expression whose value is profiled. TAG is the tag of the
section for counters, BASE is offset of the counter position. */
-static void
-tree_gen_const_delta_profiler (histogram_value value ATTRIBUTE_UNUSED,
+void
+gimple_gen_const_delta_profiler (histogram_value value ATTRIBUTE_UNUSED,
unsigned tag ATTRIBUTE_UNUSED,
unsigned base ATTRIBUTE_UNUSED)
{
@@ -403,8 +403,8 @@ tree_gen_const_delta_profiler (histogram_value value ATTRIBUTE_UNUSED,
counter. VALUE is the expression whose value is profiled. TAG is the
tag of the section for counters, BASE is offset of the counter position. */
-static void
-tree_gen_average_profiler (histogram_value value, unsigned tag, unsigned base)
+void
+gimple_gen_average_profiler (histogram_value value, unsigned tag, unsigned base)
{
gimple stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
@@ -424,8 +424,8 @@ tree_gen_average_profiler (histogram_value value, unsigned tag, unsigned base)
counter. VALUE is the expression whose value is profiled. TAG is the
tag of the section for counters, BASE is offset of the counter position. */
-static void
-tree_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base)
+void
+gimple_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base)
{
gimple stmt = value->hvalue.stmt;
gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
@@ -454,9 +454,6 @@ tree_profiling (void)
if (cgraph_state == CGRAPH_STATE_FINISHED)
return 0;
- tree_register_profile_hooks ();
- gimple_register_value_prof_hooks ();
-
for (node = cgraph_nodes; node; node = node->next)
{
if (!node->analyzed
@@ -479,12 +476,12 @@ tree_profiling (void)
if (! flag_branch_probabilities
&& flag_profile_values)
- tree_gen_ic_func_profiler ();
+ gimple_gen_ic_func_profiler ();
if (flag_branch_probabilities
&& flag_profile_values
&& flag_value_profile_transformations)
- value_profile_transformations ();
+ gimple_value_profile_transformations ();
/* The above could hose dominator info. Currently there is
none coming in, this is a safety valve. It should be
@@ -583,18 +580,4 @@ struct simple_ipa_opt_pass pass_ipa_tree_profile =
}
};
-
-struct profile_hooks tree_profile_hooks =
-{
- tree_init_edge_profiler, /* init_edge_profiler */
- tree_gen_edge_profiler, /* gen_edge_profiler */
- tree_gen_interval_profiler, /* gen_interval_profiler */
- tree_gen_pow2_profiler, /* gen_pow2_profiler */
- tree_gen_one_value_profiler, /* gen_one_value_profiler */
- tree_gen_const_delta_profiler, /* gen_const_delta_profiler */
- tree_gen_ic_profiler, /* gen_ic_profiler */
- tree_gen_average_profiler, /* gen_average_profiler */
- tree_gen_ior_profiler /* gen_ior_profiler */
-};
-
#include "gt-tree-profile.h"
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index 7d6b7ddbb41..414b94887fe 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -47,8 +47,6 @@ along with GCC; see the file COPYING3. If not see
#include "tree-pass.h"
#include "pointer-set.h"
-static struct value_prof_hooks *value_prof_hooks;
-
/* In this file value profile based optimizations are placed. Currently the
following optimizations are implemented (for more detailed descriptions
see comments at value_profile_transformations):
@@ -488,7 +486,7 @@ check_counter (gimple stmt, const char * name,
/* GIMPLE based transformations. */
-static bool
+bool
gimple_value_profile_transformations (void)
{
basic_block bb;
@@ -1545,14 +1543,6 @@ stringop_block_profile (gimple stmt, unsigned int *expected_align,
}
}
-struct value_prof_hooks {
- /* Find list of values for which we want to measure histograms. */
- void (*find_values_to_profile) (histogram_values *);
-
- /* Identify and exploit properties of values that are hard to analyze
- statically. See value-prof.c for more detail. */
- bool (*value_profile_transformations) (void);
-};
/* Find values inside STMT for that we want to measure histograms for
division/modulo optimization. */
@@ -1686,7 +1676,7 @@ gimple_values_to_profile (gimple stmt, histogram_values *values)
}
}
-static void
+void
gimple_find_values_to_profile (histogram_values *values)
{
basic_block bb;
@@ -1743,28 +1733,3 @@ gimple_find_values_to_profile (histogram_values *values)
}
}
-static struct value_prof_hooks gimple_value_prof_hooks = {
- gimple_find_values_to_profile,
- gimple_value_profile_transformations
-};
-
-void
-gimple_register_value_prof_hooks (void)
-{
- gcc_assert (current_ir_type () == IR_GIMPLE);
- value_prof_hooks = &gimple_value_prof_hooks;
-}
-
-/* IR-independent entry points. */
-void
-find_values_to_profile (histogram_values *values)
-{
- (value_prof_hooks->find_values_to_profile) (values);
-}
-
-bool
-value_profile_transformations (void)
-{
- return (value_prof_hooks->value_profile_transformations) ();
-}
-
diff --git a/gcc/value-prof.h b/gcc/value-prof.h
index 907cd785600..abd91706ca7 100644
--- a/gcc/value-prof.h
+++ b/gcc/value-prof.h
@@ -40,6 +40,7 @@ enum hist_type
#define HIST_TYPE_FOR_COUNTER(COUNTER) \
((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER))
+
/* The value to measure. */
struct histogram_value_t
{
@@ -70,44 +71,8 @@ DEF_VEC_ALLOC_P(histogram_value,heap);
typedef VEC(histogram_value,heap) *histogram_values;
-/* Hooks registration. */
-extern void gimple_register_value_prof_hooks (void);
-
-/* IR-independent entry points. */
-extern void find_values_to_profile (histogram_values *);
-extern bool value_profile_transformations (void);
-
-/* External declarations for edge-based profiling. */
-struct profile_hooks {
-
- /* Insert code to initialize edge profiler. */
- void (*init_edge_profiler) (void);
-
- /* Insert code to increment an edge count. */
- void (*gen_edge_profiler) (int, edge);
-
- /* Insert code to increment the interval histogram counter. */
- void (*gen_interval_profiler) (histogram_value, unsigned, unsigned);
-
- /* Insert code to increment the power of two histogram counter. */
- void (*gen_pow2_profiler) (histogram_value, unsigned, unsigned);
-
- /* Insert code to find the most common value. */
- void (*gen_one_value_profiler) (histogram_value, unsigned, unsigned);
-
- /* Insert code to find the most common value of a difference between two
- evaluations of an expression. */
- void (*gen_const_delta_profiler) (histogram_value, unsigned, unsigned);
-
- /* Insert code to find the most common indirect call */
- void (*gen_ic_profiler) (histogram_value, unsigned, unsigned);
-
- /* Insert code to find the average value of an expression. */
- void (*gen_average_profiler) (histogram_value, unsigned, unsigned);
-
- /* Insert code to ior value of an expression. */
- void (*gen_ior_profiler) (histogram_value, unsigned, unsigned);
-};
+extern void gimple_find_values_to_profile (histogram_values *);
+extern bool gimple_value_profile_transformations (void);
histogram_value gimple_histogram_value (struct function *, gimple);
histogram_value gimple_histogram_value_of_type (struct function *, gimple,
@@ -123,14 +88,23 @@ void verify_histograms (void);
void free_histograms (void);
void stringop_block_profile (gimple, unsigned int *, HOST_WIDE_INT *);
+/* In tree-profile.c. */
+extern void gimple_init_edge_profiler (void);
+extern void gimple_gen_edge_profiler (int, edge);
+extern void gimple_gen_interval_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_pow2_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_one_value_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_ic_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_ic_func_profiler (void);
+extern void gimple_gen_const_delta_profiler (histogram_value,
+ unsigned, unsigned);
+extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned);
+extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned);
+
/* In profile.c. */
extern void init_branch_prob (void);
extern void branch_prob (void);
extern void end_branch_prob (void);
-extern void tree_register_profile_hooks (void);
-
-/* In tree-profile.c. */
-extern struct profile_hooks tree_profile_hooks;
#endif /* GCC_VALUE_PROF_H */