Fix previous commit (that included unrelated changes)
authorJan Hubicka <hubicka@gcc.gnu.org>
Thu, 28 Nov 2019 14:50:19 +0000 (14:50 +0000)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 28 Nov 2019 14:50:19 +0000 (14:50 +0000)
commite01857197b5fbd660903fe8c0b4c6387780afe10
treebcb009c889eab215f1a3f29ff8e10bb1a0bca295
parentb49d29d73ac1e25e1ec7c5279d7493f9be6961bb
Fix previous commit (that included unrelated changes)

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: r278811
gcc/cgraphclones.c
gcc/profile-count.c
gcc/profile-count.h