This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Calculate scaled frequency in HOST_WIDE_INT (PR ipa/80663).
- From: Martin Liška <mliska at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Jan Hubicka <hubicka at ucw dot cz>
- Date: Thu, 18 May 2017 16:26:05 +0200
- Subject: [PATCH] Calculate scaled frequency in HOST_WIDE_INT (PR ipa/80663).
- Authentication-results: sourceware.org; auth=none
Hello.
Following simple fix removes ubsan in ipa-split.c as mentioned in the PR.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
>From f6230b40aa6f9d5a67e6231de2a26bc488dc784d Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 17 May 2017 13:23:54 +0200
Subject: [PATCH] Calculate scaled frequency in HOST_WIDE_INT (PR ipa/80663).
gcc/testsuite/ChangeLog:
2017-05-17 Martin Liska <mliska@suse.cz>
PR ipa/80663
* g++.dg/ipa/pr80663.C: New test.
gcc/ChangeLog:
2017-05-17 Martin Liska <mliska@suse.cz>
PR ipa/80663
* ipa-split.c (consider_split): Calculate scaled frequency
in HOST_WIDE_INT.
---
gcc/ipa-split.c | 7 ++++---
gcc/testsuite/g++.dg/ipa/pr80663.C | 10 ++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/g++.dg/ipa/pr80663.C
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 80fc31b52f8..9d00849a9fa 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -443,9 +443,10 @@ consider_split (struct split_point *current, bitmap non_ssa_vars,
}
/* Do not split when we would end up calling function anyway. */
- if (incoming_freq
- >= (ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency
- * PARAM_VALUE (PARAM_PARTIAL_INLINING_ENTRY_PROBABILITY) / 100))
+ HOST_WIDE_INT scaled_frequency
+ = ((HOST_WIDE_INT)ENTRY_BLOCK_PTR_FOR_FN (cfun)->frequency
+ * PARAM_VALUE (PARAM_PARTIAL_INLINING_ENTRY_PROBABILITY) / 100);
+ if (incoming_freq >= scaled_frequency)
{
/* When profile is guessed, we can not expect it to give us
realistic estimate on likelyness of function taking the
diff --git a/gcc/testsuite/g++.dg/ipa/pr80663.C b/gcc/testsuite/g++.dg/ipa/pr80663.C
new file mode 100644
index 00000000000..8a5d84bbc05
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr80663.C
@@ -0,0 +1,10 @@
+// PR ipa/80663
+// { dg-options "-O2 --param partial-inlining-entry-probability=1234567" }
+
+struct b
+{
+};
+struct d : virtual b
+{
+};
+main () { d a; }
--
2.12.2