Commit 959b8c82 by Jan Hubicka Committed by Jan Hubicka

ipa-utils.c (ipa_merge_profiles): Fix updating of fnsummary; also handle…

ipa-utils.c (ipa_merge_profiles): Fix updating of fnsummary; also handle rescaling of mismatched profiles.


	* ipa-utils.c (ipa_merge_profiles): Fix updating of fnsummary;
	also handle rescaling of mismatched profiles.
	* ipa-fnsummary.c (analyze_function): Handle speculative edges.

From-SVN: r267392
parent d0a6fcf5
2018-12-24 Jan Hubicka <hubicka@ucw.cz>
* ipa-utils.c (ipa_merge_profiles): Fix updating of fnsummary;
also handle rescaling of mismatched profiles.
* ipa-fnsummary.c (analyze_function): Handle speculative edges.
2018-12-23 Martin Sebor <msebor@redhat.com> 2018-12-23 Martin Sebor <msebor@redhat.com>
Jeff Law <law@redhat.com> Jeff Law <law@redhat.com>
...@@ -2180,6 +2180,17 @@ analyze_function_body (struct cgraph_node *node, bool early) ...@@ -2180,6 +2180,17 @@ analyze_function_body (struct cgraph_node *node, bool early)
es->call_stmt_time = this_time; es->call_stmt_time = this_time;
es->loop_depth = bb_loop_depth (bb); es->loop_depth = bb_loop_depth (bb);
edge_set_predicate (edge, &bb_predicate); edge_set_predicate (edge, &bb_predicate);
if (edge->speculative)
{
cgraph_edge *direct, *indirect;
ipa_ref *ref;
edge->speculative_call_info (direct, indirect, ref);
gcc_assert (direct == edge);
ipa_call_summary *es2
= ipa_call_summaries->get_create (indirect);
ipa_call_summaries->duplicate (edge, indirect,
es, es2);
}
} }
/* TODO: When conditional jump or swithc is known to be constant, but /* TODO: When conditional jump or swithc is known to be constant, but
...@@ -2491,7 +2502,8 @@ compute_fn_summary (struct cgraph_node *node, bool early) ...@@ -2491,7 +2502,8 @@ compute_fn_summary (struct cgraph_node *node, bool early)
ipa_update_overall_fn_summary but because computation happens in ipa_update_overall_fn_summary but because computation happens in
different order the roundoff errors result in slight changes. */ different order the roundoff errors result in slight changes. */
ipa_update_overall_fn_summary (node); ipa_update_overall_fn_summary (node);
gcc_assert (info->size == info->self_size); /* In LTO mode we may have speculative edges set. */
gcc_assert (in_lto_p || info->size == info->self_size);
} }
......
...@@ -392,6 +392,7 @@ ipa_merge_profiles (struct cgraph_node *dst, ...@@ -392,6 +392,7 @@ ipa_merge_profiles (struct cgraph_node *dst,
if (!src->definition if (!src->definition
|| !dst->definition) || !dst->definition)
return; return;
if (src->frequency < dst->frequency) if (src->frequency < dst->frequency)
src->frequency = dst->frequency; src->frequency = dst->frequency;
...@@ -416,6 +417,8 @@ ipa_merge_profiles (struct cgraph_node *dst, ...@@ -416,6 +417,8 @@ ipa_merge_profiles (struct cgraph_node *dst,
fprintf (symtab->dump_file, "Merging profiles of %s to %s\n", fprintf (symtab->dump_file, "Merging profiles of %s to %s\n",
src->dump_name (), dst->dump_name ()); src->dump_name (), dst->dump_name ());
} }
profile_count orig_count = dst->count;
if (dst->count.initialized_p () && dst->count.ipa () == dst->count) if (dst->count.initialized_p () && dst->count.ipa () == dst->count)
dst->count += src->count.ipa (); dst->count += src->count.ipa ();
else else
...@@ -644,10 +647,21 @@ ipa_merge_profiles (struct cgraph_node *dst, ...@@ -644,10 +647,21 @@ ipa_merge_profiles (struct cgraph_node *dst,
if (!preserve_body) if (!preserve_body)
src->release_body (); src->release_body ();
/* Update summary. */ /* Update summary. */
symtab->call_cgraph_removal_hooks (dst); compute_fn_summary (dst, 0);
symtab->call_cgraph_insertion_hooks (dst); }
/* We can't update CFG profile, but we can scale IPA profile. CFG
will be scaled according to dst->count after IPA passes. */
else
{
profile_count to = dst->count;
profile_count::adjust_for_ipa_scaling (&to, &orig_count);
struct cgraph_edge *e;
for (e = dst->callees; e; e = e->next_callee)
e->count = e->count.apply_scale (to, orig_count);
for (e = dst->indirect_calls; e; e = e->next_callee)
e->count = e->count.apply_scale (to, orig_count);
} }
/* TODO: if there is no match, we can scale up. */
src->decl = oldsrcdecl; src->decl = oldsrcdecl;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment