Blame SOURCES/gcc48-rh1469697-18.patch

8178f7
8178f7
	* config/i386/i386.c (PROBE_INTERVAL): Remove.
8178f7
	(get_probe_interval): New function.
8178f7
	(ix86_adjust_stack_and_probe_stack_clash): Use get_probe_interval.
8178f7
	(ix86_adjust_stack_and_probe): Likewise.
8178f7
	(output_adjust_stack_and_probe): Likewise.
8178f7
	(ix86_emit_probe_stack_range): Likewise.
8178f7
	(ix86_expand_prologue): Likewise.
8178f7
8178f7
	* gcc.dg/pr82788.c: New test.
8178f7
8178f7
diff -Nrup a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
8178f7
--- a/gcc/config/i386/i386.c	2017-11-06 09:54:43.814921056 -0700
8178f7
+++ b/gcc/config/i386/i386.c	2017-11-06 09:55:25.327589661 -0700
8178f7
@@ -9839,7 +9839,17 @@ release_scratch_register_on_entry (struc
8178f7
     }
8178f7
 }
8178f7
 
8178f7
-#define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP)
8178f7
+/* Return the probing interval for -fstack-clash-protection.  */
8178f7
+
8178f7
+static HOST_WIDE_INT
8178f7
+get_probe_interval (void)
8178f7
+{
8178f7
+  if (flag_stack_clash_protection)
8178f7
+    return (HOST_WIDE_INT_1U
8178f7
+	    << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL));
8178f7
+  else
8178f7
+    return (HOST_WIDE_INT_1U << STACK_CHECK_PROBE_INTERVAL_EXP);
8178f7
+}
8178f7
 
8178f7
 /* Emit code to adjust the stack pointer by SIZE bytes while probing it.
8178f7
 
8178f7
@@ -9911,8 +9921,7 @@ ix86_adjust_stack_and_probe_stack_clash
8178f7
   /* We're allocating a large enough stack frame that we need to
8178f7
      emit probes.  Either emit them inline or in a loop depending
8178f7
      on the size.  */
8178f7
-  HOST_WIDE_INT probe_interval
8178f7
-    = 1 << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL);
8178f7
+  HOST_WIDE_INT probe_interval = get_probe_interval ();
8178f7
   if (size <= 4 * probe_interval)
8178f7
     {
8178f7
       HOST_WIDE_INT i;
8178f7
@@ -9921,7 +9930,7 @@ ix86_adjust_stack_and_probe_stack_clash
8178f7
 	  /* Allocate PROBE_INTERVAL bytes.  */
8178f7
 	  rtx insn
8178f7
 	    = pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
8178f7
-					 GEN_INT (-PROBE_INTERVAL), -1,
8178f7
+					 GEN_INT (-probe_interval), -1,
8178f7
 					 m->fs.cfa_reg == stack_pointer_rtx);
8178f7
 	  add_reg_note (insn, REG_STACK_CHECK, const0_rtx);
8178f7
 
8178f7
@@ -10014,7 +10023,7 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
      that's the easy case.  The run-time loop is made up of 11 insns in the
8178f7
      generic case while the compile-time loop is made up of 3+2*(n-1) insns
8178f7
      for n # of intervals.  */
8178f7
-  if (size <= 5 * PROBE_INTERVAL)
8178f7
+  if (size <= 5 * get_probe_interval ())
8178f7
     {
8178f7
       HOST_WIDE_INT i, adjust;
8178f7
       bool first_probe = true;
8178f7
@@ -10023,15 +10032,15 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
 	 values of N from 1 until it exceeds SIZE.  If only one probe is
8178f7
 	 needed, this will not generate any code.  Then adjust and probe
8178f7
 	 to PROBE_INTERVAL + SIZE.  */
8178f7
-      for (i = PROBE_INTERVAL; i < size; i += PROBE_INTERVAL)
8178f7
+      for (i = get_probe_interval (); i < size; i += get_probe_interval ())
8178f7
 	{
8178f7
 	  if (first_probe)
8178f7
 	    {
8178f7
-	      adjust = 2 * PROBE_INTERVAL + dope;
8178f7
+	      adjust = 2 * get_probe_interval () + dope;
8178f7
 	      first_probe = false;
8178f7
 	    }
8178f7
 	  else
8178f7
-	    adjust = PROBE_INTERVAL;
8178f7
+	    adjust = get_probe_interval ();
8178f7
 
8178f7
 	  emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
8178f7
 				  plus_constant (Pmode, stack_pointer_rtx,
8178f7
@@ -10040,9 +10049,9 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
 	}
8178f7
 
8178f7
       if (first_probe)
8178f7
-	adjust = size + PROBE_INTERVAL + dope;
8178f7
+	adjust = size + get_probe_interval () + dope;
8178f7
       else
8178f7
-        adjust = size + PROBE_INTERVAL - i;
8178f7
+        adjust = size + get_probe_interval () - i;
8178f7
 
8178f7
       emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
8178f7
 			      plus_constant (Pmode, stack_pointer_rtx,
8178f7
@@ -10052,7 +10061,8 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
       /* Adjust back to account for the additional first interval.  */
8178f7
       last = emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
8178f7
 				     plus_constant (Pmode, stack_pointer_rtx,
8178f7
-						    PROBE_INTERVAL + dope)));
8178f7
+						    (get_probe_interval ()
8178f7
+						     + dope))));
8178f7
     }
8178f7
 
8178f7
   /* Otherwise, do the same as above, but in a loop.  Note that we must be
8178f7
@@ -10070,7 +10080,7 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
 
8178f7
       /* Step 1: round SIZE to the previous multiple of the interval.  */
8178f7
 
8178f7
-      rounded_size = size & -PROBE_INTERVAL;
8178f7
+      rounded_size = size & get_probe_interval ();
8178f7
 
8178f7
 
8178f7
       /* Step 2: compute initial and final value of the loop counter.  */
8178f7
@@ -10078,7 +10088,7 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
       /* SP = SP_0 + PROBE_INTERVAL.  */
8178f7
       emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
8178f7
 			      plus_constant (Pmode, stack_pointer_rtx,
8178f7
-					     - (PROBE_INTERVAL + dope))));
8178f7
+					     - (get_probe_interval () + dope))));
8178f7
 
8178f7
       /* LAST_ADDR = SP_0 + PROBE_INTERVAL + ROUNDED_SIZE.  */
8178f7
       emit_move_insn (sr.reg, GEN_INT (-rounded_size));
8178f7
@@ -10115,7 +10125,8 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
       /* Adjust back to account for the additional first interval.  */
8178f7
       last = emit_insn (gen_rtx_SET (VOIDmode, stack_pointer_rtx,
8178f7
 				     plus_constant (Pmode, stack_pointer_rtx,
8178f7
-						    PROBE_INTERVAL + dope)));
8178f7
+						    (get_probe_interval ()
8178f7
+						     + dope))));
8178f7
 
8178f7
       release_scratch_register_on_entry (&sr);
8178f7
     }
8178f7
@@ -10134,7 +10145,7 @@ ix86_adjust_stack_and_probe (const HOST_
8178f7
       XVECEXP (expr, 0, 1)
8178f7
 	= gen_rtx_SET (VOIDmode, stack_pointer_rtx,
8178f7
 		       plus_constant (Pmode, stack_pointer_rtx,
8178f7
-				      PROBE_INTERVAL + dope + size));
8178f7
+				      get_probe_interval () + dope + size));
8178f7
       add_reg_note (last, REG_FRAME_RELATED_EXPR, expr);
8178f7
       RTX_FRAME_RELATED_P (last) = 1;
8178f7
 
8178f7
@@ -10168,7 +10179,7 @@ output_adjust_stack_and_probe (rtx reg)
8178f7
   fputc ('\n', asm_out_file);
8178f7
 
8178f7
   /* SP = SP + PROBE_INTERVAL.  */
8178f7
-  xops[1] = GEN_INT (PROBE_INTERVAL);
8178f7
+  xops[1] = GEN_INT (get_probe_interval ());
8178f7
   output_asm_insn ("sub%z0\t{%1, %0|%0, %1}", xops);
8178f7
 
8178f7
   /* Probe at SP.  */
8178f7
@@ -10194,14 +10205,14 @@ ix86_emit_probe_stack_range (HOST_WIDE_I
8178f7
      that's the easy case.  The run-time loop is made up of 7 insns in the
8178f7
      generic case while the compile-time loop is made up of n insns for n #
8178f7
      of intervals.  */
8178f7
-  if (size <= 7 * PROBE_INTERVAL)
8178f7
+  if (size <= 7 * get_probe_interval ())
8178f7
     {
8178f7
       HOST_WIDE_INT i;
8178f7
 
8178f7
       /* Probe at FIRST + N * PROBE_INTERVAL for values of N from 1 until
8178f7
 	 it exceeds SIZE.  If only one probe is needed, this will not
8178f7
 	 generate any code.  Then probe at FIRST + SIZE.  */
8178f7
-      for (i = PROBE_INTERVAL; i < size; i += PROBE_INTERVAL)
8178f7
+      for (i = get_probe_interval (); i < size; i += get_probe_interval ())
8178f7
 	emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
8178f7
 					 -(first + i)));
8178f7
 
8178f7
@@ -10224,7 +10235,7 @@ ix86_emit_probe_stack_range (HOST_WIDE_I
8178f7
 
8178f7
       /* Step 1: round SIZE to the previous multiple of the interval.  */
8178f7
 
8178f7
-      rounded_size = size & -PROBE_INTERVAL;
8178f7
+      rounded_size = size & -get_probe_interval ();
8178f7
 
8178f7
 
8178f7
       /* Step 2: compute initial and final value of the loop counter.  */
8178f7
@@ -10291,7 +10302,7 @@ output_probe_stack_range (rtx reg, rtx e
8178f7
   fputc ('\n', asm_out_file);
8178f7
 
8178f7
   /* TEST_ADDR = TEST_ADDR + PROBE_INTERVAL.  */
8178f7
-  xops[1] = GEN_INT (PROBE_INTERVAL);
8178f7
+  xops[1] = GEN_INT (get_probe_interval ());
8178f7
   output_asm_insn ("sub%z0\t{%1, %0|%0, %1}", xops);
8178f7
 
8178f7
   /* Probe at TEST_ADDR.  */
8178f7
diff -Nrup a/gcc/testsuite/gcc.dg/pr82788.c b/gcc/testsuite/gcc.dg/pr82788.c
8178f7
--- a/gcc/testsuite/gcc.dg/pr82788.c	1969-12-31 17:00:00.000000000 -0700
8178f7
+++ b/gcc/testsuite/gcc.dg/pr82788.c	2017-11-06 09:55:10.680706587 -0700
8178f7
@@ -0,0 +1,4 @@
8178f7
+/* { dg-do run } */
8178f7
+/* { dg-options "-O2 -fstack-clash-protection --param stack-clash-protection-probe-interval=10 --param stack-clash-protection-guard-size=12" } */
8178f7
+/* { dg-require-effective-target supports_stack_clash_protection } */
8178f7
+int main() { int a[1442]; return 0;}