Verify edge probability consistency in verify_flow_info
2017-08-02 Tom de Vries <tom@codesourcery.com>
* cfghooks.c (verify_flow_info): Verify that if one outgoing edge has
probability set, all outgoing edges have probability set.
---
gcc/cfghooks.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
@@ -152,6 +152,8 @@ verify_flow_info (void)
bb->index, bb->frequency);
err = 1;
}
+ bool has_prob_uninit_edges = false;
+ bool has_prob_init_edges = false;
FOR_EACH_EDGE (e, ei, bb->succs)
{
if (last_visited [e->dest->index] == bb)
@@ -166,6 +168,13 @@ verify_flow_info (void)
e->src->index, e->dest->index);
err = 1;
}
+ if ((e->flags & EDGE_EH) == 0)
+ {
+ if (e->probability.initialized_p ())
+ has_prob_init_edges = true;
+ else
+ has_prob_uninit_edges = true;
+ }
if (!e->count.verify ())
{
error ("verify_flow_info: Wrong count of edge %i->%i",
@@ -197,6 +206,13 @@ verify_flow_info (void)
error ("wrong amount of branch edges after unconditional jump %i", bb->index);
err = 1;
}
+ if (has_prob_uninit_edges && has_prob_init_edges
+ && EDGE_COUNT (bb->succs) == 2)
+ {
+ error ("Missing edge probability after unconditional jump in bb %i",
+ bb->index);
+ err = 1;
+ }
FOR_EACH_EDGE (e, ei, bb->preds)
{