aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2004-08-04 23:37:06 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2004-08-04 21:37:06 +0000
commit878f99d22982a567cffaa1c0c21fb52e230f867d (patch)
tree14f9d312df96f3a3cf47a367e3b936b8d773c4fe /gcc
parentd4794d1a61d47a03acde40beaf0a372929212754 (diff)
downloadgcc-878f99d22982a567cffaa1c0c21fb52e230f867d.zip
gcc-878f99d22982a567cffaa1c0c21fb52e230f867d.tar.gz
gcc-878f99d22982a567cffaa1c0c21fb52e230f867d.tar.bz2
basic-block.h (profile_staus): New global variable.
* basic-block.h (profile_staus): New global variable. * cfg.c (profile_status): Declare. (check_bb_profile): Break out from ....; use profile_status (dump_flow_info): ... here. * cfgbuild.c (find_basic_blocks): Set profile_status. * cfgexpand.c (tree_expand_cfg): Likewise. * predict.c (estimate_probability): Likewise. * profile.c (branch_prob): Likewise. * tree-cfg.c (build_tree_cfg): Likewise. (dump_function_to_file): Use check_bb_profile. * tree-pretty-print (dump_bb_header): Likewise. * tree-profile.c (do_tree_profiling): Cleanup. From-SVN: r85579
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/basic-block.h9
-rw-r--r--gcc/cfg.c98
-rw-r--r--gcc/cfgbuild.c2
-rw-r--r--gcc/cfgexpand.c2
-rw-r--r--gcc/predict.c4
-rw-r--r--gcc/profile.c1
-rw-r--r--gcc/tree-cfg.c3
-rw-r--r--gcc/tree-pretty-print.c2
-rw-r--r--gcc/tree-profile.c3
10 files changed, 105 insertions, 34 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 506b4ad..9f50220 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2004-08-04 Jan Hubicka <jh@suse.cz>
+
+ * basic-block.h (profile_staus): New global variable.
+ * cfg.c (profile_status): Declare.
+ (check_bb_profile): Break out from ....; use profile_status
+ (dump_flow_info): ... here.
+ * cfgbuild.c (find_basic_blocks): Set profile_status.
+ * cfgexpand.c (tree_expand_cfg): Likewise.
+ * predict.c (estimate_probability): Likewise.
+ * profile.c (branch_prob): Likewise.
+ * tree-cfg.c (build_tree_cfg): Likewise.
+ (dump_function_to_file): Use check_bb_profile.
+ * tree-pretty-print (dump_bb_header): Likewise.
+ * tree-profile.c (do_tree_profiling): Cleanup.
+
2004-08-04 Zack Weinberg <zack@codesourcery.com>
* Makefile.in (RTL_BASE_H, RTL_H): Correct.
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index c42a66d..76f1368 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -330,6 +330,14 @@ extern int last_basic_block;
extern int n_edges;
+/* Signalize the status of profile information in the CFG. */
+extern enum profile_status
+{
+ PROFILE_ABSENT,
+ PROFILE_GUESSED,
+ PROFILE_READ
+} profile_status;
+
/* Index by basic block number, get basic block struct info. */
extern GTY(()) varray_type basic_block_info;
@@ -723,6 +731,7 @@ extern basic_block first_dom_son (enum cdi_direction, basic_block);
extern basic_block next_dom_son (enum cdi_direction, basic_block);
extern edge try_redirect_by_replacing_jump (edge, basic_block, bool);
extern void break_superblocks (void);
+extern void check_bb_profile (basic_block, FILE *);
#include "cfghooks.h"
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 4b6de6d..cee3cf2 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -94,6 +94,9 @@ alloc_pool rbi_pool;
void debug_flow_info (void);
static void free_edge (edge);
+
+/* Indicate the presence of the profile. */
+enum profile_status profile_status;
/* Called once at initialization time. */
@@ -468,6 +471,53 @@ clear_bb_flags (void)
bb->flags = 0;
}
+/* Check the consistency of profile information. We can't do that
+ in verify_flow_info, as the counts may get invalid for incompletely
+ solved graphs, later eliminating of conditionals or roundoff errors.
+ It is still practical to have them reported for debugging of simple
+ testcases. */
+void
+check_bb_profile (basic_block bb, FILE * file)
+{
+ edge e;
+ int sum = 0;
+ gcov_type lsum;
+
+ if (profile_status == PROFILE_ABSENT)
+ return;
+
+ if (bb != EXIT_BLOCK_PTR)
+ {
+ for (e = bb->succ; e; e = e->succ_next)
+ sum += e->probability;
+ if (bb->succ && abs (sum - REG_BR_PROB_BASE) > 100)
+ fprintf (file, "Invalid sum of outgoing probabilities %.1f%%\n",
+ sum * 100.0 / REG_BR_PROB_BASE);
+ lsum = 0;
+ for (e = bb->succ; e; e = e->succ_next)
+ lsum += e->count;
+ if (bb->succ && (lsum - bb->count > 100 || lsum - bb->count < -100))
+ fprintf (file, "Invalid sum of outgoing counts %i, should be %i\n",
+ (int) lsum, (int) bb->count);
+ }
+ if (bb != ENTRY_BLOCK_PTR)
+ {
+ sum = 0;
+ for (e = bb->pred; e; e = e->pred_next)
+ sum += EDGE_FREQUENCY (e);
+ if (abs (sum - bb->frequency) > 100)
+ fprintf (file,
+ "Invalid sum of incomming frequencies %i, should be %i\n",
+ sum, bb->frequency);
+ lsum = 0;
+ for (e = bb->pred; e; e = e->pred_next)
+ lsum += e->count;
+ if (lsum - bb->count > 100 || lsum - bb->count < -100)
+ fprintf (file, "Invalid sum of incomming counts %i, should be %i\n",
+ (int) lsum, (int) bb->count);
+ }
+}
+
void
dump_flow_info (FILE *file)
{
@@ -527,8 +577,6 @@ dump_flow_info (FILE *file)
FOR_EACH_BB (bb)
{
edge e;
- int sum;
- gcov_type lsum;
fprintf (file, "\nBasic block %d ", bb->index);
fprintf (file, "prev %d, next %d, ",
@@ -555,39 +603,23 @@ dump_flow_info (FILE *file)
fprintf (file, "\nRegisters live at end:");
dump_regset (bb->global_live_at_end, file);
-
+
putc ('\n', file);
- /* Check the consistency of profile information. We can't do that
- in verify_flow_info, as the counts may get invalid for incompletely
- solved graphs, later eliminating of conditionals or roundoff errors.
- It is still practical to have them reported for debugging of simple
- testcases. */
- sum = 0;
- for (e = bb->succ; e; e = e->succ_next)
- sum += e->probability;
- if (bb->succ && abs (sum - REG_BR_PROB_BASE) > 100)
- fprintf (file, "Invalid sum of outgoing probabilities %.1f%%\n",
- sum * 100.0 / REG_BR_PROB_BASE);
- sum = 0;
- for (e = bb->pred; e; e = e->pred_next)
- sum += EDGE_FREQUENCY (e);
- if (abs (sum - bb->frequency) > 100)
- fprintf (file,
- "Invalid sum of incomming frequencies %i, should be %i\n",
- sum, bb->frequency);
- lsum = 0;
- for (e = bb->pred; e; e = e->pred_next)
- lsum += e->count;
- if (lsum - bb->count > 100 || lsum - bb->count < -100)
- fprintf (file, "Invalid sum of incomming counts %i, should be %i\n",
- (int)lsum, (int)bb->count);
- lsum = 0;
- for (e = bb->succ; e; e = e->succ_next)
- lsum += e->count;
- if (bb->succ && (lsum - bb->count > 100 || lsum - bb->count < -100))
- fprintf (file, "Invalid sum of incomming counts %i, should be %i\n",
- (int)lsum, (int)bb->count);
+ if (bb->global_live_at_start)
+ {
+ fprintf (file, "\nRegisters live at start:");
+ dump_regset (bb->global_live_at_start, file);
+ }
+
+ if (bb->global_live_at_end)
+ {
+ fprintf (file, "\nRegisters live at end:");
+ dump_regset (bb->global_live_at_end, file);
+ }
+
+ putc ('\n', file);
+ check_bb_profile (bb, file);
}
putc ('\n', file);
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index 3316f02..cb451ef 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -546,6 +546,8 @@ find_basic_blocks (rtx f, int nregs ATTRIBUTE_UNUSED,
find_basic_blocks_1 (f);
+ profile_status = PROFILE_ABSENT;
+
/* Discover the edges of our cfg. */
make_edges (ENTRY_BLOCK_PTR->next_bb, EXIT_BLOCK_PTR->prev_bb, 0);
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index aa59118..faa4635 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -433,6 +433,8 @@ tree_expand_cfg (void)
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)));
}
+ profile_status = PROFILE_ABSENT;
+
/* Some backends want to know that we are expanding to RTL. */
currently_expanding_to_rtl = 1;
diff --git a/gcc/predict.c b/gcc/predict.c
index e55427d..d89282d 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -805,6 +805,8 @@ estimate_probability (struct loops *loops_info)
}
estimate_bb_frequencies (loops_info);
free_dominance_info (CDI_POST_DOMINATORS);
+ if (profile_status == PROFILE_ABSENT)
+ profile_status = PROFILE_GUESSED;
}
@@ -988,6 +990,8 @@ tree_estimate_probability (void)
flow_loops_free (&loops_info);
if (dump_file && (dump_flags & TDF_DETAILS))
dump_tree_cfg (dump_file, dump_flags);
+ if (profile_status == PROFILE_ABSENT)
+ profile_status = PROFILE_GUESSED;
}
/* __builtin_expect dropped tokens into the insn stream describing expected
diff --git a/gcc/profile.c b/gcc/profile.c
index ad62f87..002e7a1 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -1005,6 +1005,7 @@ branch_prob (void)
}
free_edge_list (el);
+ profile_status = PROFILE_READ;
}
/* Union find algorithm implementation for the basic blocks using
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 5765316..86ac7ee 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -125,6 +125,7 @@ build_tree_cfg (tree *tp)
/* Initialize the basic block array. */
init_flow ();
+ profile_status = PROFILE_ABSENT;
n_basic_blocks = 0;
last_basic_block = 0;
VARRAY_BB_INIT (basic_block_info, initial_cfg_capacity, "basic_block_info");
@@ -4396,6 +4397,7 @@ dump_function_to_file (tree fn, FILE *file, int flags)
if (basic_block_info)
{
/* Make a CFG based dump. */
+ check_bb_profile (ENTRY_BLOCK_PTR, file);
if (!ignore_topmost_bind)
fprintf (file, "{\n");
@@ -4406,6 +4408,7 @@ dump_function_to_file (tree fn, FILE *file, int flags)
dump_generic_bb (file, bb, 2, flags);
fprintf (file, "}\n");
+ check_bb_profile (EXIT_BLOCK_PTR, file);
}
else
{
diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c
index a3a3a01..1821700 100644
--- a/gcc/tree-pretty-print.c
+++ b/gcc/tree-pretty-print.c
@@ -2144,6 +2144,8 @@ dump_bb_header (pretty_printer *buffer, basic_block bb, int indent, int flags)
pp_newline (buffer);
}
}
+ pp_write_text_to_stream (buffer);
+ check_bb_profile (bb, buffer->buffer->stream);
}
/* Dumps end of basic block BB to buffer BUFFER indented by INDENT
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index c1498ea..1a7b744 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -146,7 +146,8 @@ tree_gen_const_delta_profiler (struct histogram_value *value ATTRIBUTE_UNUSED,
If it is, set up hooks for tree-based profiling.
Gate for pass_tree_profile. */
-static bool do_tree_profiling (void) {
+static bool do_tree_profiling (void)
+{
if (flag_tree_based_profiling)
{
tree_register_profile_hooks ();