]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix cgraph_node::apply_scale
authorJan Hubicka <hubicka@ucw.cz>
Tue, 17 Jun 2025 15:20:04 +0000 (17:20 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Tue, 17 Jun 2025 15:25:54 +0000 (17:25 +0200)
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.

gcc/cgraph.cc

index 93353cbcb683bfe105333c3f1add96d77daab275..2441c9e866d530c8ccdadfa7ed8c142909f63cab 100644 (file)
@@ -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)
        {