Blame SOURCES/gcc48-rh1537828-2.patch

b89248
commit f7765f70e0e254fd9ce4469c7281c69cd06c9467
b89248
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
b89248
Date:   Wed Jan 24 21:57:16 2018 +0000
b89248
b89248
            PR target/83994
b89248
            * i386.c (get_probe_interval): Move to earlier point.
b89248
            (ix86_compute_frame_layout): If -fstack-clash-protection and
b89248
            the frame is larger than the probe interval, then use pushes
b89248
            to save registers rather than reg->mem moves.
b89248
            (ix86_expand_prologue): Remove conditional for int_registers_saved
b89248
            assertion.
b89248
b89248
            PR target/83994
b89248
            * gcc.target/i386/pr83994.c: New test.
b89248
b89248
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
b89248
index 15cfe83..5230227 100644
b89248
--- a/gcc/config/i386/i386.c
b89248
+++ b/gcc/config/i386/i386.c
b89248
@@ -9371,6 +9371,18 @@ ix86_builtin_setjmp_frame_value (void)
b89248
   return stack_realign_fp ? hard_frame_pointer_rtx : virtual_stack_vars_rtx;
b89248
 }
b89248
 
b89248
+/* Return the probing interval for -fstack-clash-protection.  */
b89248
+
b89248
+static HOST_WIDE_INT
b89248
+get_probe_interval (void)
b89248
+{
b89248
+  if (flag_stack_clash_protection)
b89248
+    return (HOST_WIDE_INT_1U
b89248
+	    << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL));
b89248
+  else
b89248
+    return (HOST_WIDE_INT_1U << STACK_CHECK_PROBE_INTERVAL_EXP);
b89248
+}
b89248
+
b89248
 /* When using -fsplit-stack, the allocation routines set a field in
b89248
    the TCB to the bottom of the stack plus this much space, measured
b89248
    in bytes.  */
b89248
@@ -9545,7 +9557,15 @@ ix86_compute_frame_layout (struct ix86_frame *frame)
b89248
   to_allocate = offset - frame->sse_reg_save_offset;
b89248
 
b89248
   if ((!to_allocate && frame->nregs <= 1)
b89248
-      || (TARGET_64BIT && to_allocate >= (HOST_WIDE_INT) 0x80000000))
b89248
+      || (TARGET_64BIT && to_allocate >= (HOST_WIDE_INT) 0x80000000)
b89248
+      /* If stack clash probing needs a loop, then it needs a
b89248
+	 scratch register.  But the returned register is only guaranteed
b89248
+	 to be safe to use after register saves are complete.  So if
b89248
+	 stack clash protections are enabled and the allocated frame is
b89248
+	 larger than the probe interval, then use pushes to save
b89248
+	 callee saved registers.  */
b89248
+      || (flag_stack_clash_protection && to_allocate > get_probe_interval ()))
b89248
+
b89248
     frame->save_regs_using_mov = false;
b89248
 
b89248
   if (ix86_using_red_zone ()
b89248
@@ -10181,18 +10201,6 @@ release_scratch_register_on_entry (struct scratch_reg *sr)
b89248
     }
b89248
 }
b89248
 
b89248
-/* Return the probing interval for -fstack-clash-protection.  */
b89248
-
b89248
-static HOST_WIDE_INT
b89248
-get_probe_interval (void)
b89248
-{
b89248
-  if (flag_stack_clash_protection)
b89248
-    return (HOST_WIDE_INT_1U
b89248
-	    << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL));
b89248
-  else
b89248
-    return (HOST_WIDE_INT_1U << STACK_CHECK_PROBE_INTERVAL_EXP);
b89248
-}
b89248
-
b89248
 /* Emit code to adjust the stack pointer by SIZE bytes while probing it.
b89248
 
b89248
    This differs from the next routine in that it tries hard to prevent
b89248
@@ -11064,12 +11072,11 @@ ix86_expand_prologue (void)
b89248
       && (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
b89248
 	  || flag_stack_clash_protection))
b89248
     {
b89248
-      /* This assert wants to verify that integer registers were saved
b89248
-	 prior to probing.  This is necessary when probing may be implemented
b89248
-	 as a function call (Windows).  It is not necessary for stack clash
b89248
-	 protection probing.  */
b89248
-      if (!flag_stack_clash_protection)
b89248
-	gcc_assert (int_registers_saved);
b89248
+      /* We expect the GP registers to be saved when probes are used
b89248
+	 as the probing sequences might need a scratch register and
b89248
+	 the routine to allocate one assumes the integer registers
b89248
+	 have already been saved.  */
b89248
+      gcc_assert (int_registers_saved);
b89248
 
b89248
       if (flag_stack_clash_protection)
b89248
 	{
b89248
diff --git a/gcc/testsuite/gcc.target/i386/pr83994.c b/gcc/testsuite/gcc.target/i386/pr83994.c
b89248
new file mode 100644
b89248
index 0000000..dc0b7cb
b89248
--- /dev/null
b89248
+++ b/gcc/testsuite/gcc.target/i386/pr83994.c
b89248
@@ -0,0 +1,16 @@
b89248
+/* { dg-do compile } */
b89248
+/* { dg-options "-O2 -march=i686 -fpic -fstack-clash-protection" } */
b89248
+/* { dg-require-effective-target ia32 } */
b89248
+
b89248
+void f1 (char *);
b89248
+
b89248
+__attribute__ ((regparm (3)))
b89248
+int
b89248
+f2 (int arg1, int arg2, int arg3)
b89248
+{
b89248
+  char buf[16384];
b89248
+  f1 (buf);
b89248
+  f1 (buf);
b89248
+  return 0;
b89248
+}
b89248
+