Fix profile adjusments while cloning
authorJan Hubicka <hubicka@ucw.cz>
Thu, 28 Nov 2019 14:44:08 +0000 (15:44 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 28 Nov 2019 14:44:08 +0000 (14:44 +0000)
commitb49d29d73ac1e25e1ec7c5279d7493f9be6961bb
tree226f1a5e36253ed76580b40f21d20e56fd1212ea
parenteb081fd0e2cb852c3cf0ef09da497ed3fee77029
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
gcc/ChangeLog
gcc/cgraphclones.c
gcc/profile-count.c
gcc/profile-count.h