I managed to reproduce the ICE. The error is verification error about
callgraph edge count being different from basic block count of the
corresponding call stmt. This verification is only done for local profiles,
since IPA profiles are scaled during inlining, cloning and other
transformations.
Ipa-cp has logic special casis self recursive functions and it adjust
probability of the recursion to avoid non-sential IPA profiles. Normally
this is not done for local profiles, however in case the IPA profile
is broken enought the earlier logic will push clone profiles to be local
which in turn causes the verifier error.
This patch simply disables the update. Its main purpose is to keep IPA
profile seemingly meaningful and the upate is never applied back to
gimple code. Alternative would be to add machinery to adjust frequencies
of call edges, but I do not think it is worth the effort at this moment.
Bootstrapped/regtested x86_64-linux, comitted.
gcc/ChangeLog:
* ipa-cp.cc (update_counts_for_self_gen_clones): Do not update
call frequency for local profiles.
if (den > 0)
for (cgraph_edge *e = cs; e; e = get_next_cgraph_edge_clone (e))
if (e->callee->ultimate_alias_target () == orig_node
- && processed_edges.contains (e))
+ && processed_edges.contains (e)
+ /* If count is not IPA, this adjustment makes verifier
+ unhappy, since we expect bb->count to match e->count.
+ We may add a flag to mark edge conts that has been
+ modified by IPA code, but so far it does not seem
+ to be worth the effort. With local counts the profile
+ will not propagate at IPA level. */
+ && e->count.ipa_p ())
e->count /= den;
}
}