aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2017-07-04 19:05:26 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2017-07-04 17:05:26 +0000
commitfd78e43e0d0fac3b7081a2cbaad430c2c411c2e1 (patch)
tree6b34853c6e28812d63c41fbaaeeda5cef4c47c77 /gcc
parenta4187dab5248cb42781fa6b2f57b95214c4f8b03 (diff)
downloadgcc-fd78e43e0d0fac3b7081a2cbaad430c2c411c2e1.zip
gcc-fd78e43e0d0fac3b7081a2cbaad430c2c411c2e1.tar.gz
gcc-fd78e43e0d0fac3b7081a2cbaad430c2c411c2e1.tar.bz2
ipa-utils.c (ipa_merge_profiles): Fix merging when dst is uninitialized while src is not.
* ipa-utils.c (ipa_merge_profiles): Fix merging when dst is uninitialized while src is not. From-SVN: r249973
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/ipa-utils.c19
2 files changed, 20 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ccb1bd4..1168a3a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-04 Jan Hubicka <hubicka@ucw.cz>
+
+ * ipa-utils.c (ipa_merge_profiles): Fix merging when dst is
+ uninitialized while src is not.
+
2017-07-04 Richard Earnshaw <rearnsha@arm.com>
* common/config/arm/arm-common.c: Adjust include path for
diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c
index 65eed77..708710d 100644
--- a/gcc/ipa-utils.c
+++ b/gcc/ipa-utils.c
@@ -404,14 +404,17 @@ ipa_merge_profiles (struct cgraph_node *dst,
/* FIXME when we merge in unknown profile, we ought to set counts as
unsafe. */
- if (!dst->count.initialized_p ())
+ if (!src->count.initialized_p ())
return;
if (symtab->dump_file)
{
fprintf (symtab->dump_file, "Merging profiles of %s to %s\n",
src->dump_name (), dst->dump_name ());
}
- dst->count += src->count;
+ if (dst->count.initialized_p ())
+ dst->count += src->count;
+ else
+ dst->count = src->count;
/* This is ugly. We need to get both function bodies into memory.
If declaration is merged, we need to duplicate it to be able
@@ -521,12 +524,20 @@ ipa_merge_profiles (struct cgraph_node *dst,
unsigned int i;
dstbb = BASIC_BLOCK_FOR_FN (dstcfun, srcbb->index);
- dstbb->count += srcbb->count;
+ if (dstbb->count.initialized_p ())
+ dstbb->count += srcbb->count;
+ else
+ dstbb->count = srcbb->count;
for (i = 0; i < EDGE_COUNT (srcbb->succs); i++)
{
edge srce = EDGE_SUCC (srcbb, i);
edge dste = EDGE_SUCC (dstbb, i);
- dste->count += srce->count;
+ if (dstbb->count.initialized_p ())
+ dste->count += srce->count;
+ else
+ dste->count = srce->count;
+ if (dstbb->count > 0 && dste->count.initialized_p ())
+ dste->probability = dste->count.probability_in (dstbb->count);
}
}
push_cfun (dstcfun);