]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix profile after fnsplit
authorJan Hubicka <hubicka@ucw.cz>
Sat, 21 Jun 2025 20:29:50 +0000 (22:29 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Sat, 21 Jun 2025 20:30:29 +0000 (22:30 +0200)
when splitting functions, tree-inline determined correctly entry count of the
new function part, but then in case entry block of new function part is in a
loop it scales body which is not suposed to happen.

* tree-inline.cc (copy_cfg_body): Fix profile of split functions.

gcc/tree-inline.cc

index b25705173433580b73649b002cb512300c81f885..dee2dfc2620635fd571a8bdfc718f1dd53f14d3b 100644 (file)
@@ -3084,7 +3084,7 @@ copy_cfg_body (copy_body_data * id,
   /* Register specific tree functions.  */
   gimple_register_cfg_hooks ();
 
-  /* If we are inlining just region of the function, make sure to connect
+  /* If we are offlining region of the function, make sure to connect
      new entry to ENTRY_BLOCK_PTR_FOR_FN (cfun).  Since new entry can be
      part of loop, we must compute frequency and probability of
      ENTRY_BLOCK_PTR_FOR_FN (cfun) based on the frequencies and
@@ -3093,12 +3093,14 @@ copy_cfg_body (copy_body_data * id,
     {
       edge e;
       edge_iterator ei;
-      den = profile_count::zero ();
+      ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = profile_count::zero ();
 
       FOR_EACH_EDGE (e, ei, new_entry->preds)
        if (!e->src->aux)
-         den += e->count ();
-      ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = den;
+         ENTRY_BLOCK_PTR_FOR_FN (cfun)->count += e->count ();
+      /* Do not scale - the profile of offlined region should
+        remain unchanged.  */
+      num = den = profile_count::one ();
     }
 
   profile_count::adjust_for_ipa_scaling (&num, &den);