aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphclones.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2019-11-28 15:44:08 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2019-11-28 14:44:08 +0000
commitb49d29d73ac1e25e1ec7c5279d7493f9be6961bb (patch)
tree226f1a5e36253ed76580b40f21d20e56fd1212ea /gcc/cgraphclones.c
parenteb081fd0e2cb852c3cf0ef09da497ed3fee77029 (diff)
downloadgcc-b49d29d73ac1e25e1ec7c5279d7493f9be6961bb.zip
gcc-b49d29d73ac1e25e1ec7c5279d7493f9be6961bb.tar.gz
gcc-b49d29d73ac1e25e1ec7c5279d7493f9be6961bb.tar.bz2
Fix profile adjusments while cloning
This patch fixes profile updates while cloning. When new clone is produced its global profile is subtracted from the original function. If the original function profile drops to 0 we want to switch from global profiles to global0 profiles which is implemented by combine_with_ipa_count_within. However this is done on all edges independnetly and it may happen that we end up combining global and globa0 profiles in one functions which is not a good idea. This implements profile_count::combine_with_ipa_count_within which is able to take into account that the counter is inside function with a given count. * profile-count.h (profile_count::combine_with_ipa_count_within): Declare. * profile-count.c (profile_count::combine_with_ipa_count_within): New. * cgraphclones.c (cgraph_edge::clone, cgraph_node::create_clone): Use it. From-SVN: r278810
Diffstat (limited to 'gcc/cgraphclones.c')
-rw-r--r--gcc/cgraphclones.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index ac5c57a..64ff1c0 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -80,6 +80,11 @@ along with GCC; see the file COPYING3. If not see
#include "tree-inline.h"
#include "dumpfile.h"
#include "gimple-pretty-print.h"
+#include "alloc-pool.h"
+#include "symbol-summary.h"
+#include "tree-vrp.h"
+#include "ipa-prop.h"
+#include "ipa-fnsummary.h"
/* Create clone of edge in the node N represented by CALL_EXPR
the callgraph. */
@@ -136,8 +141,9 @@ cgraph_edge::clone (cgraph_node *n, gcall *call_stmt, unsigned stmt_uid,
/* Update IPA profile. Local profiles need no updating in original. */
if (update_original)
- count = count.combine_with_ipa_count (count.ipa ()
- - new_edge->count.ipa ());
+ count = count.combine_with_ipa_count_within (count.ipa ()
+ - new_edge->count.ipa (),
+ caller->count);
symtab->call_edge_duplication_hooks (this, new_edge);
return new_edge;
}
@@ -268,6 +274,8 @@ cgraph_node::expand_all_artificial_thunks ()
thunk->thunk.thunk_p = false;
thunk->analyze ();
}
+ ipa_analyze_node (thunk);
+ inline_analyze_function (thunk);
thunk->expand_all_artificial_thunks ();
}
else
@@ -341,7 +349,14 @@ cgraph_node::create_clone (tree new_decl, profile_count prof_count,
/* Update IPA profile. Local profiles need no updating in original. */
if (update_original)
- count = count.combine_with_ipa_count (count.ipa () - prof_count.ipa ());
+ {
+ if (inlined_to)
+ count = count.combine_with_ipa_count_within (count.ipa ()
+ - prof_count.ipa (),
+ inlined_to->count);
+ else
+ count = count.combine_with_ipa_count (count.ipa () - prof_count.ipa ());
+ }
new_node->decl = new_decl;
new_node->register_symbol ();
new_node->origin = origin;