aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-03-29 12:42:51 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-03-29 12:42:51 +0100
commita6240447c4eb5e683cf439fa2f3cff3773f6d6fb (patch)
treef2977d6c6568cfb8342e14782ea3ae4cdf095ae4 /gcc
parent34f95cbdc5310b9ca88df0a705b615b03b685e65 (diff)
downloadgcc-a6240447c4eb5e683cf439fa2f3cff3773f6d6fb.zip
gcc-a6240447c4eb5e683cf439fa2f3cff3773f6d6fb.tar.gz
gcc-a6240447c4eb5e683cf439fa2f3cff3773f6d6fb.tar.bz2
re PR rtl-optimization/87485 (Compile time hog w/ -O2 -fschedule-insns -fno-guess-branch-probability -fno-isolate-erroneous-paths-dereference -fno-omit-frame-pointer -fno-split-wide-types -fno-tree-ccp -fno-tree-sra)
PR rtl-optimization/87485 * function.c (expand_function_end): Move stack_protect_epilogue before loading of return value into hard register(s). * gcc.dg/pr87485.c: New test. From-SVN: r270013
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/function.c10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr87485.c29
4 files changed, 49 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 167c37e..155d208 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-03-29 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/87485
+ * function.c (expand_function_end): Move stack_protect_epilogue
+ before loading of return value into hard register(s).
+
2019-03-28 Jakub Jelinek <jakub@redhat.com>
PR middle-end/89621
diff --git a/gcc/function.c b/gcc/function.c
index bf5ba3d..c6e862b 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5330,6 +5330,12 @@ expand_function_end (void)
communicate between __builtin_eh_return and the epilogue. */
expand_eh_return ();
+ /* If stack protection is enabled for this function, check the guard. */
+ if (crtl->stack_protect_guard
+ && targetm.stack_protect_runtime_enabled_p ()
+ && naked_return_label == NULL_RTX)
+ stack_protect_epilogue ();
+
/* If scalar return value was computed in a pseudo-reg, or was a named
return value that got dumped to the stack, copy that to the hard
return register. */
@@ -5476,7 +5482,9 @@ expand_function_end (void)
emit_insn (gen_blockage ());
/* If stack protection is enabled for this function, check the guard. */
- if (crtl->stack_protect_guard && targetm.stack_protect_runtime_enabled_p ())
+ if (crtl->stack_protect_guard
+ && targetm.stack_protect_runtime_enabled_p ()
+ && naked_return_label)
stack_protect_epilogue ();
/* If we had calls to alloca, and this machine needs
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1c48361..07274c62 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-03-29 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/87485
+ * gcc.dg/pr87485.c: New test.
+
2019-03-28 Jakub Jelinek <jakub@redhat.com>
PR middle-end/89621
diff --git a/gcc/testsuite/gcc.dg/pr87485.c b/gcc/testsuite/gcc.dg/pr87485.c
new file mode 100644
index 0000000..7e09173
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87485.c
@@ -0,0 +1,29 @@
+/* PR rtl-optimization/87485 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -fschedule-insns -fno-guess-branch-probability -fno-isolate-erroneous-paths-dereference -fno-omit-frame-pointer -fno-split-wide-types -fno-tree-ccp -fno-tree-sra" } */
+/* { dg-additional-options "-fstack-protector-strong" { target fstack_protector } } */
+
+int *a;
+
+int
+foo (__int128 x, int y, int z)
+{
+ __int128 b;
+ *a = ((!!y ? y : x) * y | x) * 2;
+ if (z == 0)
+ {
+ unsigned int c = 1;
+ __int128 *d = &b;
+ for (*a = 0; *a < 1; *a += y)
+ ;
+ *a += b < (c / 0); /* { dg-warning "division by zero" } */
+ goto l;
+ m:
+ while (b < 1)
+ ;
+ ++*a;
+ }
+ goto m;
+ l:
+ return 0;
+}