ipa-inline-transform.c: Include function.h, cfg.h and basic-block.h
authorJan Hubicka <hubicka@ucw.cz>
Sat, 10 Jun 2017 23:18:44 +0000 (01:18 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sat, 10 Jun 2017 23:18:44 +0000 (23:18 +0000)
* ipa-inline-transform.c: Include function.h, cfg.h and basic-block.h
(mark_all_inlined_calls_cdtor): Fix formating.
(inline_transform): Rescale profile before inlining.

From-SVN: r249098

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

index 7964c5b06a3e224f0e80b7032b2211ff73fbcd98..d35bd6d4fecfc6616d66cf697c3dd4281b17be82 100644 (file)
@@ -1,3 +1,9 @@
+2017-06-10  Jan Hubicka  <hubicka@ucw.cz>
+
+       * ipa-inline-transform.c: Include function.h, cfg.h and basic-block.h
+       (mark_all_inlined_calls_cdtor): Fix formating.
+       (inline_transform): Rescale profile before inlining.
+
 2017-06-10  Jan Hubicka  <hubicka@ucw.cz>
 
        * cgraph.h (cgraph_edge::clone): Update prototype.
index 01a6833349359a7d57a1c33385557a62a915f506..9866a55e8b56579d11d2b16b90838ae1bfa2d2db 100644 (file)
@@ -44,6 +44,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-fnsummary.h"
 #include "ipa-inline.h"
 #include "tree-inline.h"
+#include "function.h"
+#include "cfg.h"
+#include "basic-block.h"
 
 int ncalls_inlined;
 int nfunctions_inlined;
@@ -276,7 +279,7 @@ mark_all_inlined_calls_cdtor (cgraph_node *node)
     {
       cs->in_polymorphic_cdtor = true;
       if (!cs->inline_failed)
-    mark_all_inlined_calls_cdtor (cs->callee);
+       mark_all_inlined_calls_cdtor (cs->callee);
     }
   for (cgraph_edge *cs = node->indirect_calls; cs; cs = cs->next_callee)
     cs->in_polymorphic_cdtor = true;
@@ -661,7 +664,37 @@ inline_transform (struct cgraph_node *node)
 
   timevar_push (TV_INTEGRATION);
   if (node->callees && (opt_for_fn (node->decl, optimize) || has_inline))
-    todo = optimize_inline_calls (current_function_decl);
+    {
+      profile_count num = node->count;
+      profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
+      bool scale = num.initialized_p ()
+                  && (den > 0 || num == profile_count::zero ())
+                  && !(num == den);
+      if (scale)
+       {
+         if (dump_file)
+           {
+             fprintf (dump_file, "Applying count scale ");
+             num.dump (dump_file);
+             fprintf (dump_file, "/");
+             den.dump (dump_file);
+             fprintf (dump_file, "\n");
+           }
+
+         basic_block bb;
+         FOR_ALL_BB_FN (bb, cfun)
+           {
+             bb->count = bb->count.apply_scale (num, den);
+       
+             edge e;
+             edge_iterator ei;
+             FOR_EACH_EDGE (e, ei, bb->succs)
+               e->count = e->count.apply_scale (num, den);
+           }
+         ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
+       }
+      todo = optimize_inline_calls (current_function_decl);
+   }
   timevar_pop (TV_INTEGRATION);
 
   cfun->always_inline_functions_inlined = true;