summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-05 17:34:16 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-05 17:34:16 +0000
commita2e423212fcde0a5659145ea2ac4de626297fc14 (patch)
tree4c6b7e31c08d36c2ce332bfd0f07dda9240944d1 /gcc
parentc9fc348751f70ebf0e19713529ed9f6bd747da43 (diff)
downloadgcc-a2e423212fcde0a5659145ea2ac4de626297fc14.tar.gz
* cfg.c (dump_flow_info): Warn about profile mismatches.
* cfgrtl.c (verify_flow_info): Few aditional sanity checks. (purge_dead_edges): Remove REG_BR_PROB notes on simplejumps. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50320 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cfg.c35
-rw-r--r--gcc/cfgrtl.c52
3 files changed, 92 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 13fb80d7c17..fac38921ebd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+Tue Mar 5 18:31:27 CET 2002 Jan Hubicka <jh@suse.cz>
+
+ * cfg.c (dump_flow_info): Warn about profile mismatches.
+ * cfgrtl.c (verify_flow_info): Few aditional sanity checks.
+ (purge_dead_edges): Remove REG_BR_PROB notes on simplejumps.
+
2002-03-05 Jakub Jelinek <jakub@redhat.com>
* expmed.c (emit_store_flag): Don't test BITS_PER_WORD * 2
diff --git a/gcc/cfg.c b/gcc/cfg.c
index a33beffd0b2..433d10accf9 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -505,8 +505,10 @@ dump_flow_info (file)
fprintf (file, "\n%d basic blocks, %d edges.\n", n_basic_blocks, n_edges);
for (i = 0; i < n_basic_blocks; i++)
{
- basic_block bb = BASIC_BLOCK (i);
+ basic_block bb = BASIC_BLOCK (i), dom_bb;
edge e;
+ int sum;
+ gcov_type lsum;
fprintf (file, "\nBasic block %d: first insn %d, last %d, ",
i, INSN_UID (bb->head), INSN_UID (bb->end));
@@ -529,6 +531,37 @@ dump_flow_info (file)
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 elliminating 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);
}
putc ('\n', file);
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index a45d4a37f7e..151502087ac 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -1651,7 +1651,36 @@ verify_flow_info ()
basic_block bb = BASIC_BLOCK (i);
int has_fallthru = 0;
edge e;
+ rtx note;
+ if (INSN_P (bb->end)
+ && (note = find_reg_note (bb->end, REG_BR_PROB, NULL_RTX)))
+ {
+ if (!any_condjump_p (bb->end))
+ {
+ error ("verify_flow_info: REG_BR_PROB on non-condjump",
+ bb->index);
+ err = 1;
+ }
+ if (INTVAL (XEXP (note, 0)) != BRANCH_EDGE (bb)->probability)
+ {
+ error ("verify_flow_info: REG_BR_PROB does not match cfg %i %i",
+ INTVAL (XEXP (note, 0)), BRANCH_EDGE (bb)->probability);
+ err = 1;
+ }
+ }
+ if (bb->count < 0)
+ {
+ error ("verify_flow_info: Wrong count of block %i %i",
+ bb->index, (int)bb->count);
+ err = 1;
+ }
+ if (bb->frequency < 0)
+ {
+ error ("verify_flow_info: Wrong frequency of block %i %i",
+ bb->index, bb->frequency);
+ err = 1;
+ }
for (e = bb->succ; e; e = e->succ_next)
{
if (last_visited [e->dest->index + 2] == bb)
@@ -1660,6 +1689,18 @@ verify_flow_info ()
e->src->index, e->dest->index);
err = 1;
}
+ if (e->probability < 0 || e->probability > REG_BR_PROB_BASE)
+ {
+ error ("verify_flow_info: Wrong probability of edge %i->%i %i",
+ e->src->index, e->dest->index, e->probability);
+ err = 1;
+ }
+ if (e->count < 0)
+ {
+ error ("verify_flow_info: Wrong count of edge %i->%i %i",
+ e->src->index, e->dest->index, (int)e->count);
+ err = 1;
+ }
last_visited [e->dest->index + 2] = bb;
@@ -1935,6 +1976,17 @@ purge_dead_edges (bb)
&& !simplejump_p (insn))
return false;
+ /* Branch probability/prediction notes are defined only for
+ condjumps. We've possibly turned condjump into simplejump. */
+ if (simplejump_p (insn))
+ {
+ note = find_reg_note (insn, REG_BR_PROB, NULL);
+ if (note)
+ remove_note (insn, note);
+ while ((note = find_reg_note (insn, REG_BR_PRED, NULL)))
+ remove_note (insn, note);
+ }
+
for (e = bb->succ; e; e = next)
{
next = e->succ_next;