[gcc(refs/users/wschmidt/heads/dd2)] rs6000: More restrictions on -mrop-protect

William Schmidt wschmidt@gcc.gnu.org
Thu Mar 18 20:06:14 GMT 2021


https://gcc.gnu.org/g:89672be464fdb5f7cdd23e4a5500ebf314d4bc41

commit 89672be464fdb5f7cdd23e4a5500ebf314d4bc41
Author: Bill Schmidt <wschmidt@linux.ibm.com>
Date:   Thu Mar 18 15:05:55 2021 -0500

    rs6000: More restrictions on -mrop-protect
    
    2021-03-18  Bill Schmidt  <wschmidt@linux.ibm.com>
    
    gcc/
            * config/rs6000/rs6000-logue.c (rs6000_stack_info): Move ROP logic
            after calls_p set; depend upon calls_p; depend upon
            TARGET_POWER10.
            (rs6000_emit_prologue): Depend upon TARGET_POWER10.
            (rs6000_emit_epilogue): Likewise.

Diff:
---
 gcc/config/rs6000/rs6000-logue.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c
index 81d3f0e1f68..7dbdecc98cf 100644
--- a/gcc/config/rs6000/rs6000-logue.c
+++ b/gcc/config/rs6000/rs6000-logue.c
@@ -716,18 +716,19 @@ rs6000_stack_info (void)
   info->altivec_size = 16 * (LAST_ALTIVEC_REGNO + 1
 				 - info->first_altivec_reg_save);
 
-  if (DEFAULT_ABI == ABI_ELFv2 && rs6000_rop_protect)
+  /* Does this function call anything (apart from sibling calls)?  */
+  info->calls_p = (!crtl->is_leaf || cfun->machine->ra_needs_full_frame);
+
+  if (TARGET_POWER10 && info->calls_p
+      && DEFAULT_ABI == ABI_ELFv2 && rs6000_rop_protect)
     info->rop_check_size = 8;
-  else if (rs6000_rop_protect)
+  else if (rs6000_rop_protect && DEFAULT_ABI != ABI_ELFv2)
     /* We can't check this in rs6000_option_override_internal since
        DEFAULT_ABI isn't established yet.  */
     error ("%qs requires the ELFv2 ABI", "-mrop-protect");
   else
     info->rop_check_size = 0;
 
-  /* Does this function call anything (apart from sibling calls)?  */
-  info->calls_p = (!crtl->is_leaf || cfun->machine->ra_needs_full_frame);
-
   /* Determine if we need to save the condition code registers.  */
   if (save_reg_p (CR2_REGNO)
       || save_reg_p (CR3_REGNO)
@@ -3070,7 +3071,7 @@ rs6000_emit_prologue (void)
     }
 
   /* The ROP hash store must occur before a stack frame is created.  */
-  if (rs6000_rop_protect && info->push_p)
+  if (TARGET_POWER10 && rs6000_rop_protect && info->push_p)
     {
       gcc_assert (DEFAULT_ABI == ABI_ELFv2);
       rtx stack_ptr = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
@@ -5021,9 +5022,8 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type)
 
   /* The ROP hash check must occur after the stack pointer is restored,
      and is not performed for a sibcall.  */
-  if (rs6000_rop_protect
-      && info->push_p
-      && epilogue_type != EPILOGUE_TYPE_SIBCALL)
+  if (TARGET_POWER10 && rs6000_rop_protect
+      && info->push_p && epilogue_type != EPILOGUE_TYPE_SIBCALL)
     {
       gcc_assert (DEFAULT_ABI == ABI_ELFv2);
       rtx stack_ptr = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);


More information about the Gcc-cvs mailing list