From 09fcc0c01d21bec1f7e1f40a4400c9248a2e5ca7 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sun, 11 Jun 2017 01:18:44 +0200 Subject: [PATCH] ipa-inline-transform.c: Include function.h, cfg.h and basic-block.h * 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 | 6 ++++++ gcc/ipa-inline-transform.c | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7964c5b06a3..d35bd6d4fec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-06-10 Jan Hubicka + + * 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 * cgraph.h (cgraph_edge::clone): Update prototype. diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c index 01a68333493..9866a55e8b5 100644 --- a/gcc/ipa-inline-transform.c +++ b/gcc/ipa-inline-transform.c @@ -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; -- 2.30.2