13f101
commit 8a1b46d59d6c3e1e5eb606cd44689c8557612257
13f101
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
13f101
Date:   Wed Sep 20 05:21:09 2017 +0000
13f101
13f101
            * config/alpha/alpha.c (alpha_expand_prologue): Also check
13f101
            flag_stack_clash_protection.
13f101
            * config/ia64/ia64.c (ia64_compute_frame_size): Likewise.
13f101
            (ia64_expand_prologue): Likewise.
13f101
            * config/mips/mips.c (mips_expand_prologue): Likewise.
13f101
            * config/sparc/sparc.c (sparc_expand_prologue): Likewise.
13f101
            (sparc_flat_expand_prologue): Likewise.
13f101
            * config/spu/spu.c (spu_expand_prologue): Likewise.
13f101
    
13f101
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252996 138bc75d-0d04-0410-961f-82ee72b054a4
13f101
13f101
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
13f101
index 5402f5213d6..c46c843e462 100644
13f101
--- a/gcc/config/alpha/alpha.c
13f101
+++ b/gcc/config/alpha/alpha.c
13f101
@@ -7624,7 +7624,7 @@ alpha_expand_prologue (void)
13f101
      Note that we are only allowed to adjust sp once in the prologue.  */
13f101
 
13f101
   probed_size = frame_size;
13f101
-  if (flag_stack_check)
13f101
+  if (flag_stack_check || flag_stack_clash_protection)
13f101
     probed_size += get_stack_check_protect ();
13f101
 
13f101
   if (probed_size <= 32768)
13f101
@@ -7639,7 +7639,7 @@ alpha_expand_prologue (void)
13f101
 	  /* We only have to do this probe if we aren't saving registers or
13f101
 	     if we are probing beyond the frame because of -fstack-check.  */
13f101
 	  if ((sa_size == 0 && probed_size > probed - 4096)
13f101
-	      || flag_stack_check)
13f101
+	      || flag_stack_check || flag_stack_clash_protection)
13f101
 	    emit_insn (gen_probe_stack (GEN_INT (-probed_size)));
13f101
 	}
13f101
 
13f101
@@ -7669,7 +7669,8 @@ alpha_expand_prologue (void)
13f101
 	 late in the compilation, generate the loop as a single insn.  */
13f101
       emit_insn (gen_prologue_stack_probe_loop (count, ptr));
13f101
 
13f101
-      if ((leftover > 4096 && sa_size == 0) || flag_stack_check)
13f101
+      if ((leftover > 4096 && sa_size == 0)
13f101
+	  || flag_stack_check || flag_stack_clash_protection)
13f101
 	{
13f101
 	  rtx last = gen_rtx_MEM (DImode,
13f101
 				  plus_constant (Pmode, ptr, -leftover));
13f101
@@ -7677,7 +7678,7 @@ alpha_expand_prologue (void)
13f101
 	  emit_move_insn (last, const0_rtx);
13f101
 	}
13f101
 
13f101
-      if (flag_stack_check)
13f101
+      if (flag_stack_check || flag_stack_clash_protection)
13f101
 	{
13f101
 	  /* If -fstack-check is specified we have to load the entire
13f101
 	     constant into a register and subtract from the sp in one go,
13f101
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
13f101
index 390983936e8..5bf7046cf15 100644
13f101
--- a/gcc/config/ia64/ia64.c
13f101
+++ b/gcc/config/ia64/ia64.c
13f101
@@ -2638,7 +2638,8 @@ ia64_compute_frame_size (HOST_WIDE_INT size)
13f101
     mark_reg_gr_used_mask (cfun->machine->ia64_eh_epilogue_bsp, NULL);
13f101
 
13f101
   /* Static stack checking uses r2 and r3.  */
13f101
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
13f101
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
13f101
+      || flag_stack_clash_protection)
13f101
     current_frame_info.gr_used_mask |= 0xc;
13f101
 
13f101
   /* Find the size of the register stack frame.  We have only 80 local
13f101
@@ -3434,7 +3435,8 @@ ia64_expand_prologue (void)
13f101
   if (flag_stack_usage_info)
13f101
     current_function_static_stack_size = current_frame_info.total_size;
13f101
 
13f101
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
13f101
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
13f101
+      || flag_stack_clash_protection)
13f101
     ia64_emit_probe_stack_range (get_stack_check_protect (),
13f101
 				 current_frame_info.total_size,
13f101
 				 current_frame_info.n_input_regs
13f101
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
13f101
index 9b7eb678f19..da17f94b4f9 100644
13f101
--- a/gcc/config/mips/mips.c
13f101
+++ b/gcc/config/mips/mips.c
13f101
@@ -10745,7 +10745,9 @@ mips_expand_prologue (void)
13f101
   if (flag_stack_usage_info)
13f101
     current_function_static_stack_size = size;
13f101
 
13f101
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK && size)
13f101
+  if ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
13f101
+       || flag_stack_clash_protection)
13f101
+      && size)
13f101
     mips_emit_probe_stack_range (get_stack_check_protect (), size);
13f101
 
13f101
   /* Save the registers.  Allocate up to MIPS_MAX_FIRST_STACK_STEP
13f101
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
13f101
index e5e93c80261..617aa617208 100644
13f101
--- a/gcc/config/sparc/sparc.c
13f101
+++ b/gcc/config/sparc/sparc.c
13f101
@@ -5430,7 +5430,9 @@ sparc_expand_prologue (void)
13f101
   if (flag_stack_usage_info)
13f101
     current_function_static_stack_size = size;
13f101
 
13f101
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK && size)
13f101
+  if ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
13f101
+       || flag_stack_clash_protection)
13f101
+      && size)
13f101
     sparc_emit_probe_stack_range (get_stack_check_protect (), size);
13f101
 
13f101
   if (size == 0)
13f101
@@ -5532,7 +5534,9 @@ sparc_flat_expand_prologue (void)
13f101
   if (flag_stack_usage_info)
13f101
     current_function_static_stack_size = size;
13f101
 
13f101
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK && size)
13f101
+  if ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
13f101
+       || flag_stack_clash_protection)
13f101
+      && size)
13f101
     sparc_emit_probe_stack_range (get_stack_check_protect (), size);
13f101
 
13f101
   if (sparc_save_local_in_regs_p)
13f101
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
13f101
index 328bd5bd2ae..5541a3cd243 100644
13f101
--- a/gcc/config/spu/spu.c
13f101
+++ b/gcc/config/spu/spu.c
13f101
@@ -1761,7 +1761,7 @@ spu_expand_prologue (void)
13f101
 
13f101
   if (total_size > 0)
13f101
     {
13f101
-      if (flag_stack_check)
13f101
+      if (flag_stack_check || flag_stack_clash_protection)
13f101
 	{
13f101
 	  /* We compare against total_size-1 because
13f101
 	     ($sp >= total_size) <=> ($sp > total_size-1) */
13f101
@@ -5366,7 +5366,7 @@ spu_allocate_stack (rtx op0, rtx op1)
13f101
   emit_insn (gen_spu_convert (sp, stack_pointer_rtx));
13f101
   emit_insn (gen_subv4si3 (sp, sp, splatted));
13f101
 
13f101
-  if (flag_stack_check)
13f101
+  if (flag_stack_check || flag_stack_clash_protection)
13f101
     {
13f101
       rtx avail = gen_reg_rtx(SImode);
13f101
       rtx result = gen_reg_rtx(SImode);