ipa-inline-transform.c (update_noncloned_frequencies): Update also counts.
authorJan Hubicka <hubicka@ucw.cz>
Fri, 16 Jun 2017 11:41:19 +0000 (13:41 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 16 Jun 2017 11:41:19 +0000 (11:41 +0000)
* ipa-inline-transform.c (update_noncloned_frequencies): Update also
counts.
(clone_inlined_nodes): Update.

From-SVN: r249244

gcc/ChangeLog
gcc/ipa-inline-transform.c

index 219dc1230e140be5a66ed07b815472c4086bb02d..0fed0dce4cc65c8cc34cabaa4f8ba102bbb87f9e 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-16  Jan Hubicka  <hubicka@ucw.cz>
+
+       * ipa-inline-transform.c (update_noncloned_frequencies): Update also
+       counts.
+       (clone_inlined_nodes): Update.
+
 2017-06-16  Maxim Kuvyrkov  <maxim.kuvyrkov@linaro.org>
 
         * config/aarch64/aarch64.c (qdf24xx_prefetch_tune): Update
index 9866a55e8b56579d11d2b16b90838ae1bfa2d2db..dc224f7a39469abdcd6ecb1c1a955552ee07fdba 100644 (file)
@@ -54,10 +54,12 @@ int nfunctions_inlined;
 /* Scale frequency of NODE edges by FREQ_SCALE.  */
 
 static void
-update_noncloned_frequencies (struct cgraph_node *node,
-                             int freq_scale)
+update_noncloned_frequencies (struct cgraph_node *node, 
+                             int freq_scale, profile_count num,
+                             profile_count den)
 {
   struct cgraph_edge *e;
+  bool scale = (num == profile_count::zero () || den > 0);
 
   /* We do not want to ignore high loop nest after freq drops to 0.  */
   if (!freq_scale)
@@ -68,14 +70,20 @@ update_noncloned_frequencies (struct cgraph_node *node,
       if (e->frequency > CGRAPH_FREQ_MAX)
         e->frequency = CGRAPH_FREQ_MAX;
       if (!e->inline_failed)
-        update_noncloned_frequencies (e->callee, freq_scale);
+        update_noncloned_frequencies (e->callee, freq_scale, num, den);
+      if (scale)
+       e->count = e->count.apply_scale (num, den);
     }
   for (e = node->indirect_calls; e; e = e->next_callee)
     {
       e->frequency = e->frequency * (gcov_type) freq_scale / CGRAPH_FREQ_BASE;
       if (e->frequency > CGRAPH_FREQ_MAX)
         e->frequency = CGRAPH_FREQ_MAX;
+      if (scale)
+       e->count = e->count.apply_scale (num, den);
     }
+  if (scale)
+    node->count = node->count.apply_scale (num, den);
 }
 
 /* We removed or are going to remove the last call to NODE.
@@ -212,7 +220,8 @@ clone_inlined_nodes (struct cgraph_edge *e, bool duplicate,
            }
          duplicate = false;
          e->callee->externally_visible = false;
-          update_noncloned_frequencies (e->callee, e->frequency);
+          update_noncloned_frequencies (e->callee, e->frequency,
+                                       e->count, e->callee->count);
 
          dump_callgraph_transformation (e->callee, inlining_into,
                                         "inlining to");