alpha.c (alpha_expand_prologue): Also check flag_stack_clash_protection.
authorJeff Law <law@redhat.com>
Wed, 20 Sep 2017 05:21:09 +0000 (23:21 -0600)
committerJeff Law <law@gcc.gnu.org>
Wed, 20 Sep 2017 05:21:09 +0000 (23:21 -0600)
* config/alpha/alpha.c (alpha_expand_prologue): Also check
flag_stack_clash_protection.
* config/arm/arm.c (arm_compute_static_chain_stack_bytes): Likewise.
(arm_expand_prologue, thumb1_expand_prologue): Likewise.
(arm_frame_pointer_required): Likewise.
* config/ia64/ia64.c (ia64_compute_frame_size): Likewise.
(ia64_expand_prologue): Likewise.
* config/mips/mips.c (mips_expand_prologue): Likewise.
* config/powerpcspe/powerpcspe.c (rs6000_expand_prologue): Likewise.
* config/sparc/sparc.c (sparc_expand_prologue): Likewise.
(sparc_flat_expand_prologue): Likewise.
* config/spu/spu.c (spu_expand_prologue): Likewise.

From-SVN: r252996

gcc/ChangeLog
gcc/config/alpha/alpha.c
gcc/config/arm/arm.c
gcc/config/ia64/ia64.c
gcc/config/mips/mips.c
gcc/config/powerpcspe/powerpcspe.c
gcc/config/sparc/sparc.c
gcc/config/spu/spu.c

index b80126114053578fe435690d32cde2cee35ff5e5..070692c5053c6ecf58d91a8425fb0b1fa8aaffe1 100644 (file)
@@ -1,5 +1,18 @@
 2017-09-19  Jeff Law  <law@redhat.com>
 
+       * config/alpha/alpha.c (alpha_expand_prologue): Also check
+       flag_stack_clash_protection.
+       * config/arm/arm.c (arm_compute_static_chain_stack_bytes): Likewise.
+       (arm_expand_prologue, thumb1_expand_prologue): Likewise.
+       (arm_frame_pointer_required): Likewise.
+       * config/ia64/ia64.c (ia64_compute_frame_size): Likewise.
+       (ia64_expand_prologue): Likewise.
+       * config/mips/mips.c (mips_expand_prologue): Likewise.
+       * config/powerpcspe/powerpcspe.c (rs6000_expand_prologue): Likewise.
+       * config/sparc/sparc.c (sparc_expand_prologue): Likewise.
+       (sparc_flat_expand_prologue): Likewise.
+       * config/spu/spu.c (spu_expand_prologue): Likewise.
+
        * explow.c: Include "params.h".
        (anti_adjust_stack_and_probe_stack_clash): New function.
        (get_stack_check_protect): Likewise.
index a4e8b2b6c3014e86a7ef5ec527a0570bfea60b30..41f3e3a195780a70003cfb5de505a146ef039287 100644 (file)
@@ -7760,7 +7760,7 @@ alpha_expand_prologue (void)
      Note that we are only allowed to adjust sp once in the prologue.  */
 
   probed_size = frame_size;
-  if (flag_stack_check)
+  if (flag_stack_check || flag_stack_clash_protection)
     probed_size += get_stack_check_protect ();
 
   if (probed_size <= 32768)
@@ -7775,7 +7775,7 @@ alpha_expand_prologue (void)
          /* We only have to do this probe if we aren't saving registers or
             if we are probing beyond the frame because of -fstack-check.  */
          if ((sa_size == 0 && probed_size > probed - 4096)
-             || flag_stack_check)
+             || flag_stack_check || flag_stack_clash_protection)
            emit_insn (gen_probe_stack (GEN_INT (-probed_size)));
        }
 
@@ -7805,7 +7805,8 @@ alpha_expand_prologue (void)
         late in the compilation, generate the loop as a single insn.  */
       emit_insn (gen_prologue_stack_probe_loop (count, ptr));
 
-      if ((leftover > 4096 && sa_size == 0) || flag_stack_check)
+      if ((leftover > 4096 && sa_size == 0)
+         || flag_stack_check || flag_stack_clash_protection)
        {
          rtx last = gen_rtx_MEM (DImode,
                                  plus_constant (Pmode, ptr, -leftover));
@@ -7813,7 +7814,7 @@ alpha_expand_prologue (void)
          emit_move_insn (last, const0_rtx);
        }
 
-      if (flag_stack_check)
+      if (flag_stack_check || flag_stack_clash_protection)
        {
          /* If -fstack-check is specified we have to load the entire
             constant into a register and subtract from the sp in one go,
index 679e838b0aaefa75250c109bf555108096cbaab5..d97f88719c57c3d587586e1e4bdce251f89ad521 100644 (file)
@@ -19164,7 +19164,8 @@ arm_compute_static_chain_stack_bytes (void)
   /* See the defining assertion in arm_expand_prologue.  */
   if (IS_NESTED (arm_current_func_type ())
       && ((TARGET_APCS_FRAME && frame_pointer_needed && TARGET_ARM)
-         || (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+         || ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+              || flag_stack_clash_protection)
              && !df_regs_ever_live_p (LR_REGNUM)))
       && arm_r3_live_at_start_p ()
       && crtl->args.pretend_args_size == 0)
@@ -21466,7 +21467,8 @@ arm_expand_prologue (void)
      clobbered when creating the frame, we need to save and restore it.  */
   clobber_ip = IS_NESTED (func_type)
               && ((TARGET_APCS_FRAME && frame_pointer_needed && TARGET_ARM)
-                  || (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+                  || ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+                       || flag_stack_clash_protection)
                       && !df_regs_ever_live_p (LR_REGNUM)
                       && arm_r3_live_at_start_p ()));
 
@@ -21680,7 +21682,8 @@ arm_expand_prologue (void)
      stack checking.  We use IP as the first scratch register, except for the
      non-APCS nested functions if LR or r3 are available (see clobber_ip).  */
   if (!IS_INTERRUPT (func_type)
-      && flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+      && (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+         || flag_stack_clash_protection))
     {
       unsigned int regno;
 
@@ -24991,7 +24994,9 @@ thumb1_expand_prologue (void)
     current_function_static_stack_size = size;
 
   /* If we have a frame, then do stack checking.  FIXME: not implemented.  */
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK && size)
+  if ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+       || flag_stack_clash_protection)
+      && size)
     sorry ("-fstack-check=specific for Thumb-1");
 
   amount = offsets->outgoing_args - offsets->saved_regs;
@@ -27871,7 +27876,8 @@ arm_frame_pointer_required (void)
      instruction prior to the stack adjustment and this requires a frame
      pointer if we want to catch the exception using the EABI unwinder.  */
   if (!IS_INTERRUPT (arm_current_func_type ())
-      && flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+      && (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+         || flag_stack_clash_protection)
       && arm_except_unwind_info (&global_options) == UI_TARGET
       && cfun->can_throw_non_call_exceptions)
     {
index 00ef2159323e05b0b57f5bb34ec8164b3120fe07..f34f2f852474a2148869eabd6dd65e9449c18ef0 100644 (file)
@@ -2704,7 +2704,8 @@ ia64_compute_frame_size (HOST_WIDE_INT size)
     mark_reg_gr_used_mask (cfun->machine->ia64_eh_epilogue_bsp, NULL);
 
   /* Static stack checking uses r2 and r3.  */
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+      || flag_stack_clash_protection)
     current_frame_info.gr_used_mask |= 0xc;
 
   /* Find the size of the register stack frame.  We have only 80 local
@@ -3494,7 +3495,8 @@ ia64_expand_prologue (void)
   if (flag_stack_usage_info)
     current_function_static_stack_size = current_frame_info.total_size;
 
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+      || flag_stack_clash_protection)
     {
       HOST_WIDE_INT size = current_frame_info.total_size;
       int bs_size = BACKING_STORE_SIZE (current_frame_info.n_input_regs
index 67cee0bb0519bd98394000aabd5ba2e3b9a288b6..8643cb9ad303b28672d6f59eca22b31cdc8a7eb1 100644 (file)
@@ -12080,7 +12080,8 @@ mips_expand_prologue (void)
   if (flag_stack_usage_info)
     current_function_static_stack_size = size;
 
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+      || flag_stack_clash_protection)
     {
       if (crtl->is_leaf && !cfun->calls_alloca)
        {
index a956729f7065d5085e3d78e61eb7bc9a1a6c578e..e235d3c6a82392d0371522a477588b75e0ca2503 100644 (file)
@@ -29687,7 +29687,8 @@ rs6000_emit_prologue (void)
   if (flag_stack_usage_info)
     current_function_static_stack_size = info->total_size;
 
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+      || flag_stack_check_protection)
     {
       HOST_WIDE_INT size = info->total_size;
 
index 906bd75b560ef48e705ad1bf7587ce492de5ca78..11e4f4565a52239a73fab9984b02c1c287a30e6d 100644 (file)
@@ -5734,7 +5734,8 @@ sparc_expand_prologue (void)
   if (flag_stack_usage_info)
     current_function_static_stack_size = size;
 
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+      || flag_stack_clash_protection)
     {
       if (crtl->is_leaf && !cfun->calls_alloca)
        {
@@ -5845,7 +5846,8 @@ sparc_flat_expand_prologue (void)
   if (flag_stack_usage_info)
     current_function_static_stack_size = size;
 
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK
+      || flag_stack_clash_protection)
     {
       if (crtl->is_leaf && !cfun->calls_alloca)
        {
index a35f0b8636b0743156bf8fd897eca32540b7e9da..1fc997722865ae4ba02496b4906be680d4000f20 100644 (file)
@@ -1767,7 +1767,7 @@ spu_expand_prologue (void)
 
   if (total_size > 0)
     {
-      if (flag_stack_check)
+      if (flag_stack_check || flag_stack_clash_protection)
        {
          /* We compare against total_size-1 because
             ($sp >= total_size) <=> ($sp > total_size-1) */
@@ -5390,7 +5390,7 @@ spu_allocate_stack (rtx op0, rtx op1)
   emit_insn (gen_spu_convert (sp, stack_pointer_rtx));
   emit_insn (gen_subv4si3 (sp, sp, splatted));
 
-  if (flag_stack_check)
+  if (flag_stack_check || flag_stack_clash_protection)
     {
       rtx avail = gen_reg_rtx(SImode);
       rtx result = gen_reg_rtx(SImode);