Blame SOURCES/gcc48-rh1469697-18.patch

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