From d4006ff3fa68d8f0fc9f8c9f953296e78c4cb277 Mon Sep 17 00:00:00 2001 From: hubicka Date: Thu, 3 Jan 2019 10:19:03 +0000 Subject: [PATCH] * ipa-utils.c (scale_ipa_profile_for_fn): Break out from ... (ipa_merge_profiles): ... here; do not ICE on thunks and aliases. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267549 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/ipa-utils.c | 33 +++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 634de2b0d18c..d1b1876354d6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-01-03 Jan Hubicka + + * ipa-utils.c (scale_ipa_profile_for_fn): Break out from ... + (ipa_merge_profiles): ... here; do not ICE on thunks and aliases. + 2019-01-02 Martin Sebor Jeff Law diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c index c9723759f502..aebcb8ea91d4 100644 --- a/gcc/ipa-utils.c +++ b/gcc/ipa-utils.c @@ -375,6 +375,20 @@ get_base_var (tree t) return t; } +/* Scale function of calls in NODE by ratio ORIG_COUNT/NODE->count. */ + +void +scale_ipa_profile_for_fn (struct cgraph_node *node, profile_count orig_count) +{ + profile_count to = node->count; + profile_count::adjust_for_ipa_scaling (&to, &orig_count); + struct cgraph_edge *e; + + for (e = node->callees; e; e = e->next_callee) + e->count = e->count.apply_scale (to, orig_count); + for (e = node->indirect_calls; e; e = e->next_callee) + e->count = e->count.apply_scale (to, orig_count); +} /* SRC and DST are going to be merged. Take SRC's profile and merge it into DST so it is not going to be lost. Possibly destroy SRC's body on the way @@ -424,6 +438,14 @@ ipa_merge_profiles (struct cgraph_node *dst, else dst->count = src->count.ipa (); + /* First handle functions with no gimple body. */ + if (dst->thunk.thunk_p || dst->alias + || src->thunk.thunk_p || src->alias) + { + scale_ipa_profile_for_fn (dst, orig_count); + return; + } + /* This is ugly. We need to get both function bodies into memory. If declaration is merged, we need to duplicate it to be able to load body that is being replaced. This makes symbol table @@ -652,16 +674,7 @@ ipa_merge_profiles (struct cgraph_node *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); - } + scale_ipa_profile_for_fn (dst, orig_count); src->decl = oldsrcdecl; } -- 2.47.2