Ping * 2.   [Message-ID: <1e003d78-3b2e-4263-830a-7c00a3e9d...@linux.ibm.com>]

Segher, this resolves the issues you mentioned in your review.

Peter



On 6/18/24 5:59 PM, Peter Bergner wrote:
> Updated patch.  This passed bootstrap and regtesting on powerpc64le-linux
> with no regressions.  Ok for trunk?
>
> Changes from v1:
>     1. Moved the disabling of shrink-wrapping to rs6000_emit_prologue
>        and beefed up comment.  Used a more accurate test.
>     2. Added comment to the test case on why rop_ok is needed.
>
> Peter
>
>
> rs6000: ROP - Do not disable shrink-wrapping for leaf functions [PR114759]
>
> Only disable shrink-wrapping when using -mrop-protect when we know we
> will be emitting the ROP-protect hash instructions (ie, non-leaf functions).
>
> 2024-06-17  Peter Bergner  <berg...@linux.ibm.com>
>
> gcc/
>       PR target/114759
>       * config/rs6000/rs6000.cc (rs6000_override_options_after_change): Move
>       the disabling of shrink-wrapping from here....
>       * config/rs6000/rs6000-logue.cc (rs6000_emit_prologue): ...to here.
>
> gcc/testsuite/
>       PR target/114759
>       * gcc.target/powerpc/pr114759-1.c: New test.
> ---
>  gcc/config/rs6000/rs6000-logue.cc             |  5 +++++
>  gcc/config/rs6000/rs6000.cc                   |  4 ----
>  gcc/testsuite/gcc.target/powerpc/pr114759-1.c | 16 ++++++++++++++++
>  3 files changed, 21 insertions(+), 4 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/powerpc/pr114759-1.c
>
> diff --git a/gcc/config/rs6000/rs6000-logue.cc 
> b/gcc/config/rs6000/rs6000-logue.cc
> index 193e2122c0f..c384e48e378 100644
> --- a/gcc/config/rs6000/rs6000-logue.cc
> +++ b/gcc/config/rs6000/rs6000-logue.cc
> @@ -3018,6 +3018,11 @@ rs6000_emit_prologue (void)
>                             && (lookup_attribute ("no_split_stack",
>                                                   DECL_ATTRIBUTES 
> (cfun->decl))
>                                 == NULL));
> +  /* If we are inserting ROP-protect hash instructions, disable shrink-wrap
> +     until the bug where the hashst insn is emitted in the wrong location
> +     is fixed.  See PR101324 for details.  */
> +  if (info->rop_hash_size)
> +    flag_shrink_wrap = 0;
>  
>    frame_pointer_needed_indeed
>      = frame_pointer_needed && df_regs_ever_live_p 
> (HARD_FRAME_POINTER_REGNUM);
> diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
> index e4dc629ddcc..fd6e013c346 100644
> --- a/gcc/config/rs6000/rs6000.cc
> +++ b/gcc/config/rs6000/rs6000.cc
> @@ -3427,10 +3427,6 @@ rs6000_override_options_after_change (void)
>      }
>    else if (!OPTION_SET_P (flag_cunroll_grow_size))
>      flag_cunroll_grow_size = flag_peel_loops || optimize >= 3;
> -
> -  /* If we are inserting ROP-protect instructions, disable shrink wrap.  */
> -  if (rs6000_rop_protect)
> -    flag_shrink_wrap = 0;
>  }
>  
>  #ifdef TARGET_USES_LINUX64_OPT
> diff --git a/gcc/testsuite/gcc.target/powerpc/pr114759-1.c 
> b/gcc/testsuite/gcc.target/powerpc/pr114759-1.c
> new file mode 100644
> index 00000000000..579e08e920f
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/pr114759-1.c
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect 
> -fdump-rtl-pro_and_epilogue" } */
> +/* { dg-require-effective-target rop_ok } Only enable on supported ABIs. */
> +
> +/* Verify we still attempt shrink-wrapping when using -mrop-protect
> +   and there are no function calls.  */
> +
> +long
> +foo (long arg)
> +{
> +  if (arg)
> +    asm ("" ::: "r20");
> +  return 0;
> +}
> +
> +/* { dg-final { scan-rtl-dump-times "Performing shrink-wrapping" 1 
> "pro_and_epilogue" } } */

Reply via email to