summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2019-11-28 17:59:43 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2019-11-28 16:59:43 +0000
commitc3f1ae8a30a3d55a8d38ad8c5724edb7ca19761b (patch)
treead8b7b75e9094126bfac11196a144d55fe07511f
parent97dd1ee8de2ceb45b1572964bc2849d32cb2b322 (diff)
Prevent inconsistent profiles to be created in inlin_transform
* ipa-inline-transform.c (inline_transform): Scale profile before redirecting. From-SVN: r278814
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/ipa-inline-transform.c51
2 files changed, 31 insertions, 25 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e842cd2648d..87732c84850 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2019-11-28 Jan Hubicka <hubicka@ucw.cz>
+ * ipa-inline-transform.c (inline_transform): Scale profile before
+ redirecting.
+
+2019-11-28 Jan Hubicka <hubicka@ucw.cz>
+
* profile-count.h (profile_count::max): Work on profiles of different
type.
(profile_count::apply_scale): Be sure that ret is not local or global0
diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
index e7ec7f911e1..6ec843a23b7 100644
--- a/gcc/ipa-inline-transform.c
+++ b/gcc/ipa-inline-transform.c
@@ -681,6 +681,31 @@ inline_transform (struct cgraph_node *node)
if (preserve_function_body_p (node))
save_inline_function_body (node);
+ profile_count num = node->count;
+ profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
+ bool scale = num.initialized_p () && !(num == den);
+ if (scale)
+ {
+ profile_count::adjust_for_ipa_scaling (&num, &den);
+ 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;
+ cfun->cfg->count_max = profile_count::uninitialized ();
+ FOR_ALL_BB_FN (bb, cfun)
+ {
+ bb->count = bb->count.apply_scale (num, den);
+ cfun->cfg->count_max = cfun->cfg->count_max.max (bb->count);
+ }
+ ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
+ }
+
for (e = node->callees; e; e = next)
{
if (!e->inline_failed)
@@ -693,32 +718,8 @@ inline_transform (struct cgraph_node *node)
timevar_push (TV_INTEGRATION);
if (node->callees && (opt_for_fn (node->decl, optimize) || has_inline))
{
- profile_count num = node->count;
- profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
- bool scale = num.initialized_p () && !(num == den);
- if (scale)
- {
- profile_count::adjust_for_ipa_scaling (&num, &den);
- 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;
- cfun->cfg->count_max = profile_count::uninitialized ();
- FOR_ALL_BB_FN (bb, cfun)
- {
- bb->count = bb->count.apply_scale (num, den);
- cfun->cfg->count_max = cfun->cfg->count_max.max (bb->count);
- }
- 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;