Blame SOURCES/gcc48-rh1469697-17.patch

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