aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2020-10-15 18:30:51 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2020-10-15 18:30:51 +0100
commitbb31009f6bb62d2dbee6a4be9605c9286ef0df23 (patch)
treec19b528f867c0514b3941a7a153bcbad922a0262
parent4.9.4: mark branch as abandoned (diff)
downloadgcc-patches-bb31009f6bb62d2dbee6a4be9605c9286ef0df23.tar.gz
gcc-patches-bb31009f6bb62d2dbee6a4be9605c9286ef0df23.tar.bz2
gcc-patches-bb31009f6bb62d2dbee6a4be9605c9286ef0df23.zip
10.2.0: backport IPA to_frequency() ICE
Reported-by: inasprecali@disroot.org Bug: https://bugs.gentoo.org/746578 Bug: https://gcc.gnu.org/PR97295 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rw-r--r--10.2.0/gentoo/40_all_ipa-to_frequency.patch48
-rw-r--r--10.2.0/gentoo/README.history3
2 files changed, 51 insertions, 0 deletions
diff --git a/10.2.0/gentoo/40_all_ipa-to_frequency.patch b/10.2.0/gentoo/40_all_ipa-to_frequency.patch
new file mode 100644
index 0000000..0849207
--- /dev/null
+++ b/10.2.0/gentoo/40_all_ipa-to_frequency.patch
@@ -0,0 +1,48 @@
+https://bugs.gentoo.org/746578
+https://gcc.gnu.org/PR97295
+
+From 508e2d88a4c512e8b8685cf5ba201ad48e6bb58d Mon Sep 17 00:00:00 2001
+From: Martin Liska <mliska@suse.cz>
+Date: Tue, 13 Oct 2020 16:44:47 +0200
+Subject: [PATCH] IPA: fix profile handling in IRA
+
+gcc/ChangeLog:
+
+ PR ipa/97295
+ * profile-count.c (profile_count::to_frequency): Move part of
+ gcc_assert to STATIC_ASSERT.
+ * regs.h (REG_FREQ_FROM_BB): Do not use count.to_frequency for
+ a function that does not have count_max initialized.
+---
+ gcc/profile-count.c | 4 ++--
+ gcc/regs.h | 3 ++-
+ 2 files changed, 4 insertions(+), 3 deletions(-)
+
+--- a/gcc/profile-count.c
++++ b/gcc/profile-count.c
+@@ -270,8 +270,8 @@ profile_count::to_frequency (struct function *fun) const
+ return BB_FREQ_MAX;
+ if (*this == zero ())
+ return 0;
+- gcc_assert (REG_BR_PROB_BASE == BB_FREQ_MAX
+- && fun->cfg->count_max.initialized_p ());
++ STATIC_ASSERT (REG_BR_PROB_BASE == BB_FREQ_MAX);
++ gcc_assert (fun->cfg->count_max.initialized_p ());
+ profile_probability prob = probability_in (fun->cfg->count_max);
+ if (!prob.initialized_p ())
+ return REG_BR_PROB_BASE;
+--- a/gcc/regs.h
++++ b/gcc/regs.h
+@@ -128,7 +128,8 @@ extern size_t reg_info_p_size;
+ or profile driven feedback is available and the function is never executed,
+ frequency is always equivalent. Otherwise rescale the basic block
+ frequency. */
+-#define REG_FREQ_FROM_BB(bb) (optimize_function_for_size_p (cfun) \
++#define REG_FREQ_FROM_BB(bb) ((optimize_function_for_size_p (cfun) \
++ || !cfun->cfg->count_max.initialized_p ()) \
+ ? REG_FREQ_MAX \
+ : ((bb)->count.to_frequency (cfun) \
+ * REG_FREQ_MAX / BB_FREQ_MAX) \
+--
+2.28.0
+
diff --git a/10.2.0/gentoo/README.history b/10.2.0/gentoo/README.history
index 86f3aae..e419e62 100644
--- a/10.2.0/gentoo/README.history
+++ b/10.2.0/gentoo/README.history
@@ -1,3 +1,6 @@
+4 TODO
+ + 40_all_ipa-to_frequency.patch
+
3 02 Oct 2020
U 28_all_EXTRA_OPTIONS-fstack-clash-protection.patch
+ 37_all_c-vector-init-PR96377.patch