diff options
author | Peter Bergner <bergner@linux.ibm.com> | 2024-06-18 17:42:45 -0500 |
---|---|---|
committer | Peter Bergner <bergner@linux.ibm.com> | 2024-08-12 12:27:07 -0500 |
commit | 0451bc503da9c858e9f1ddfb8faec367c2e032c8 (patch) | |
tree | 0acf2ffbe56e98d6cee247c18bc54c9cce52aa4a /gcc | |
parent | ef90a136da4c3e0b28997da25c30fdce1bcb115c (diff) | |
download | gcc-0451bc503da9c858e9f1ddfb8faec367c2e032c8.zip gcc-0451bc503da9c858e9f1ddfb8faec367c2e032c8.tar.gz gcc-0451bc503da9c858e9f1ddfb8faec367c2e032c8.tar.bz2 |
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 <bergner@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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/rs6000/rs6000-logue.cc | 5 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.cc | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/pr114759-1.c | 16 |
3 files changed, 21 insertions, 4 deletions
diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc index edc0d6c..fdb6414 100644 --- a/gcc/config/rs6000/rs6000-logue.cc +++ b/gcc/config/rs6000/rs6000-logue.cc @@ -3012,6 +3012,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 0bcc6a2..f2bd9ed 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -3431,10 +3431,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; - /* One of the late-combine passes runs after register allocation and can match define_insn_and_splits that were previously used only before register allocation. Some of those define_insn_and_splits 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 0000000..579e08e --- /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" } } */ |