aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2017-11-03 14:30:53 -0600
committerJeff Law <law@gcc.gnu.org>2017-11-03 14:30:53 -0600
commit61959ba10bd5595e6114712abcbce5bcea36c9bf (patch)
tree5d7009708107715c7e173685f7240730e6f53547 /gcc
parent245f6de13d73c2d6c8be1b78f9e1e99e4510572c (diff)
downloadgcc-61959ba10bd5595e6114712abcbce5bcea36c9bf.zip
gcc-61959ba10bd5595e6114712abcbce5bcea36c9bf.tar.gz
gcc-61959ba10bd5595e6114712abcbce5bcea36c9bf.tar.bz2
i386.c (ix86_emit_restore_reg_using_pop): Prototype.
* config/i386/i386.c (ix86_emit_restore_reg_using_pop): Prototype. (ix86_adjust_stack_and_probe_stack_clash): Use a push/pop sequence to probe at the start of a noreturn function. * gcc.target/i386/stack-check-12.c: New test. From-SVN: r254396
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/i386/i386.c12
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/i386/stack-check-12.c19
4 files changed, 39 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 98cd5a4..99f8aba 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-03 Jeff Law <law@redhat.com>
+
+ * config/i386/i386.c (ix86_emit_restore_reg_using_pop): Prototype.
+ (ix86_adjust_stack_and_probe_stack_clash): Use a push/pop sequence
+ to probe at the start of a noreturn function.
+
2017-11-03 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/78821
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 25b28a1..1b83755 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -101,6 +101,8 @@ static void ix86_print_operand_address_as (FILE *, rtx, addr_space_t, bool);
static bool ix86_save_reg (unsigned int, bool, bool);
static bool ix86_function_naked (const_tree);
static bool ix86_notrack_prefixed_insn_p (rtx);
+static void ix86_emit_restore_reg_using_pop (rtx);
+
#ifndef CHECK_STACK_LIMIT
#define CHECK_STACK_LIMIT (-1)
@@ -12124,8 +12126,14 @@ ix86_adjust_stack_and_probe_stack_clash (const HOST_WIDE_INT size)
we just probe when we cross PROBE_INTERVAL. */
if (TREE_THIS_VOLATILE (cfun->decl))
{
- emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
- -GET_MODE_SIZE (word_mode)));
+ /* We can safely use any register here since we're just going to push
+ its value and immediately pop it back. But we do try and avoid
+ argument passing registers so as not to introduce dependencies in
+ the pipeline. For 32 bit we use %esi and for 64 bit we use %rax. */
+ rtx dummy_reg = gen_rtx_REG (word_mode, TARGET_64BIT ? AX_REG : SI_REG);
+ rtx_insn *insn = emit_insn (gen_push (dummy_reg));
+ RTX_FRAME_RELATED_P (insn) = 1;
+ ix86_emit_restore_reg_using_pop (dummy_reg);
emit_insn (gen_blockage ());
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 69d8b6b..4cc2ced 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-11-03 Jeff Law <law@redhat.com>
+
+ * gcc.target/i386/stack-check-12.c: New test.
+
2017-11-03 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/78821
diff --git a/gcc/testsuite/gcc.target/i386/stack-check-12.c b/gcc/testsuite/gcc.target/i386/stack-check-12.c
new file mode 100644
index 0000000..cb69bb0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/stack-check-12.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-clash-protection -mtune=generic" } */
+/* { dg-require-effective-target supports_stack_clash_protection } */
+
+__attribute__ ((noreturn)) void exit (int);
+
+__attribute__ ((noreturn)) void
+f (void)
+{
+ asm volatile ("nop" ::: "edi");
+ exit (1);
+}
+
+/* { dg-final { scan-assembler-not "or\[ql\]" } } */
+/* { dg-final { scan-assembler "pushl %esi" { target ia32 } } } */
+/* { dg-final { scan-assembler "popl %esi" { target ia32 } } }*/
+/* { dg-final { scan-assembler "pushq %rax" { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler "popq %rax" { target { ! ia32 } } } }*/
+