https://gcc.gnu.org/g:30e8f97a25f44b1e11275a9f46aef78d7e4e4316
commit r16-1544-g30e8f97a25f44b1e11275a9f46aef78d7e4e4316 Author: Jan Hubicka <hubi...@ucw.cz> Date: Tue Jun 17 17:20:04 2025 +0200 Fix cgraph_node::apply_scale while working on auto-FDO I noticed that we may run into ICE because we inline function with count profile_count::zero to a call site with profile_count::zero. What may go wrong is that the caller has local profile while callee may have IPA profiles. We used to turn all such counts to 0, but that has changed by a short circuit I introducd recently. Fixed thus. * cgraph.cc (cgraph_node::apply_scale): Special case scaling to profile_count::zero (). (cgraph_node::verify_node): Add extra compatibility check. Diff: --- gcc/cgraph.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index 93353cbcb683..2441c9e866d5 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -250,7 +250,7 @@ cgraph_node::make_profile_global0 (profile_quality quality) void cgraph_node::apply_scale (profile_count num, profile_count den) { - if (num == den) + if (num == den && !(num == profile_count::zero ())) return; for (cgraph_edge *e = callees; e; e = e->next_callee) @@ -3763,6 +3763,13 @@ cgraph_node::verify_node (void) count.debug (); error_found = true; } + if (inlined_to && !e->count.compatible_p (inlined_to->count)) + { + error ("edge count is not compatible with inlined to function count"); + e->count.debug (); + count.debug (); + error_found = true; + } if (!e->indirect_unknown_callee || !e->indirect_info) {