Hi,
this patch makes ICE in the testcase in PR83575 go away, it however is not
complete
fix. The problem there is that bb-reorder messes up block partitioning when
profile
is insane and we ICE on multiple hot-cold partition transitions.
This patch fixes the origin of insane profile that is caused by force_edge_cold
getting out of hand on uninitialized profile.
Martin liska has patch to fix partitining fixup in bb-reorder and I will take a
look
why that one does not seem to remove the ICE incrementally.
Bootstrapped/regtested x86_64-linux, comitted.
Honza
PR middle-end/83575
* predict.c (force_edge_cold): Handle in more sane way edges
with no prediction.
Index: predict.c
===================================================================
--- predict.c (revision 256390)
+++ predict.c (working copy)
@@ -4040,6 +4040,10 @@ force_edge_cold (edge e, bool impossible
edge e2;
bool uninitialized_exit = false;
+ /* When branch probability guesses are not known, then do nothing. */
+ if (!impossible && !e->count ().initialized_p ())
+ return;
+
profile_probability goal = (impossible ? profile_probability::never ()
: profile_probability::very_unlikely ());
@@ -4050,17 +4054,23 @@ force_edge_cold (edge e, bool impossible
FOR_EACH_EDGE (e2, ei, e->src->succs)
if (e2 != e)
{
+ if (e->flags & EDGE_FAKE)
+ continue;
if (e2->count ().initialized_p ())
count_sum += e2->count ();
- else
- uninitialized_exit = true;
if (e2->probability.initialized_p ())
prob_sum += e2->probability;
+ else
+ uninitialized_exit = true;
}
+ /* If we are not guessing profiles but have some other edges out,
+ just assume the control flow goes elsewhere. */
+ if (uninitialized_exit)
+ e->probability = goal;
/* If there are other edges out of e->src, redistribute probabilitity
there. */
- if (prob_sum > profile_probability::never ())
+ else if (prob_sum > profile_probability::never ())
{
if (!(e->probability < goal))
e->probability = goal;
@@ -4100,8 +4110,7 @@ force_edge_cold (edge e, bool impossible
update_br_prob_note (e->src);
if (e->src->count == profile_count::zero ())
return;
- if (count_sum == profile_count::zero () && !uninitialized_exit
- && impossible)
+ if (count_sum == profile_count::zero () && impossible)
{
bool found = false;
if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun))