From: Jan Hubicka Date: Thu, 18 Sep 2025 12:15:47 +0000 (+0200) Subject: Fix verification ICE after ipa-cp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c6b6adce45a550c52dc35e3df4e0c477f5404fa;p=thirdparty%2Fgcc.git Fix verification ICE after ipa-cp 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. --- diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 4f2030a8d8c..4e03c366106 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -4697,7 +4697,14 @@ update_counts_for_self_gen_clones (cgraph_node *orig_node, 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; } }