Blame SOURCES/gcc48-rh1469697-17.patch

85359c
85359c
            * config/i386/i386.c (ix86_emit_restore_reg_using_pop): Prototype.
85359c
            (ix86_adjust_stack_and_probe_stack_clash): Use a push/pop sequence
85359c
            to probe at the start of a noreturn function.
85359c
    
85359c
            * gcc.target/i386/stack-check-12.c: New test
85359c
85359c
diff -Nrup a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
85359c
--- a/gcc/config/i386/i386.c	2017-11-03 13:35:17.641528205 -0600
85359c
+++ b/gcc/config/i386/i386.c	2017-11-03 13:37:39.489361692 -0600
85359c
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.
85359c
 #include "tree-flow.h"
85359c
 
85359c
 static rtx legitimize_dllimport_symbol (rtx, bool);
85359c
+static void ix86_emit_restore_reg_using_pop (rtx);
85359c
 
85359c
 #ifndef CHECK_STACK_LIMIT
85359c
 #define CHECK_STACK_LIMIT (-1)
85359c
@@ -9884,8 +9885,14 @@ ix86_adjust_stack_and_probe_stack_clash
85359c
      we just probe when we cross PROBE_INTERVAL.  */
85359c
   if (TREE_THIS_VOLATILE (cfun->decl))
85359c
     {
85359c
-      emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
85359c
-				       -GET_MODE_SIZE (word_mode)));
85359c
+      /* We can safely use any register here since we're just going to push
85359c
+	 its value and immediately pop it back.  But we do try and avoid
85359c
+	 argument passing registers so as not to introduce dependencies in
85359c
+	 the pipeline.  For 32 bit we use %esi and for 64 bit we use %rax.  */
85359c
+      rtx dummy_reg = gen_rtx_REG (word_mode, TARGET_64BIT ? AX_REG : SI_REG);
85359c
+      rtx insn = emit_insn (gen_push (dummy_reg));
85359c
+      RTX_FRAME_RELATED_P (insn) = 1;
85359c
+      ix86_emit_restore_reg_using_pop (dummy_reg);
85359c
       emit_insn (gen_blockage ());
85359c
     }
85359c
 
85359c
diff -Nrup a/gcc/testsuite/gcc.target/i386/stack-check-12.c b/gcc/testsuite/gcc.target/i386/stack-check-12.c
85359c
--- a/gcc/testsuite/gcc.target/i386/stack-check-12.c	1969-12-31 17:00:00.000000000 -0700
85359c
+++ b/gcc/testsuite/gcc.target/i386/stack-check-12.c	2017-11-03 13:36:15.104055651 -0600
85359c
@@ -0,0 +1,19 @@
85359c
+/* { dg-do compile } */
85359c
+/* { dg-options "-O2 -fstack-clash-protection -mtune=generic -fomit-frame-pointer" } */
85359c
+/* { dg-require-effective-target supports_stack_clash_protection } */
85359c
+
85359c
+__attribute__ ((noreturn)) void exit (int);
85359c
+
85359c
+__attribute__ ((noreturn)) void
85359c
+f (void)
85359c
+{
85359c
+  asm volatile ("nop" ::: "edi");
85359c
+  exit (1);
85359c
+}
85359c
+
85359c
+/* { dg-final { scan-assembler-not "or\[ql\]" } } */
85359c
+/* { dg-final { scan-assembler "pushl	%esi" { target ia32 } } } */
85359c
+/* { dg-final { scan-assembler "popl	%esi" { target ia32 } } }*/
85359c
+/* { dg-final { scan-assembler "pushq	%rax" { target { ! ia32 } } } } */
85359c
+/* { dg-final { scan-assembler "popq	%rax" { target { ! ia32 } } } }*/
85359c
+