[v2] x86: Disable SSE on unwind-c.c and unwind-dw2.c
Commit Message
Since eh_return doesn't work with stack realignment, disable SSE on
unwind-c.c and unwind-dw2.c to avoid stack realignment with the 4-byte
incoming stack to avoid SSE usage which is caused by
commit 609e8c492d62d92465460eae3d43dfc4b2c68288
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sat Feb 26 14:17:23 2022 -0800
x86: Always return pseudo register in ix86_gen_scratch_sse_rtx
when pseudo vector registers are used to expand memset.
gcc/
PR target/104781
* config/i386/i386.cc (ix86_expand_epilogue): Assert there is
no stack realignment for eh_return.
gcc/testsuite/
PR target/104781
* gcc.target/i386/eh_return-1.c: Add -mincoming-stack-boundary=4.
* gcc.target/i386/eh_return-2.c: Likewise.
libgcc/
PR target/104781
* config.host (tmake_file): Add i386/32/t-eh-return-no-sse for
32-bit x86 Cygwin, MinGW and Solaris.
* config/i386/32/t-eh-return-no-sse: New file.
---
gcc/config/i386/i386.cc | 5 ++---
gcc/testsuite/gcc.target/i386/eh_return-1.c | 2 +-
gcc/testsuite/gcc.target/i386/eh_return-2.c | 2 +-
libgcc/config.host | 13 +++++++++++++
libgcc/config/i386/32/t-eh-return-no-sse | 5 +++++
5 files changed, 22 insertions(+), 5 deletions(-)
create mode 100644 libgcc/config/i386/32/t-eh-return-no-sse
Comments
On Mon, Mar 07, 2022 at 05:57:40AM -0800, H.J. Lu via Gcc-patches wrote:
> --- a/gcc/config/i386/i386.cc
> +++ b/gcc/config/i386/i386.cc
> @@ -9444,9 +9444,8 @@ ix86_expand_epilogue (int style)
> rtx sa = EH_RETURN_STACKADJ_RTX;
> rtx_insn *insn;
>
> - /* %ecx can't be used for both DRAP register and eh_return. */
> - if (crtl->drap_reg)
> - gcc_assert (REGNO (crtl->drap_reg) != CX_REG);
> + /* Stack realignment doesn't work with eh_return. */
> + gcc_assert (!crtl->stack_realign_needed);
Shouldn't this be error or sorry? Otherwise, won't
calls to __builtin_eh_return from random testcases where
stack realignment is needed or even with regparm nested functions
just ICE?
>
> /* regparm nested functions don't work with eh_return. */
> gcc_assert (!ix86_static_chain_on_stack);
Jakub
On Mon, Mar 7, 2022 at 6:23 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Mon, Mar 07, 2022 at 05:57:40AM -0800, H.J. Lu via Gcc-patches wrote:
> > --- a/gcc/config/i386/i386.cc
> > +++ b/gcc/config/i386/i386.cc
> > @@ -9444,9 +9444,8 @@ ix86_expand_epilogue (int style)
> > rtx sa = EH_RETURN_STACKADJ_RTX;
> > rtx_insn *insn;
> >
> > - /* %ecx can't be used for both DRAP register and eh_return. */
> > - if (crtl->drap_reg)
> > - gcc_assert (REGNO (crtl->drap_reg) != CX_REG);
> > + /* Stack realignment doesn't work with eh_return. */
> > + gcc_assert (!crtl->stack_realign_needed);
>
> Shouldn't this be error or sorry? Otherwise, won't
> calls to __builtin_eh_return from random testcases where
> stack realignment is needed or even with regparm nested functions
> just ICE?
Fixed in the v3 patch:
https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591307.html
Thanks.
> >
> > /* regparm nested functions don't work with eh_return. */
> > gcc_assert (!ix86_static_chain_on_stack);
>
> Jakub
>
@@ -9444,9 +9444,8 @@ ix86_expand_epilogue (int style)
rtx sa = EH_RETURN_STACKADJ_RTX;
rtx_insn *insn;
- /* %ecx can't be used for both DRAP register and eh_return. */
- if (crtl->drap_reg)
- gcc_assert (REGNO (crtl->drap_reg) != CX_REG);
+ /* Stack realignment doesn't work with eh_return. */
+ gcc_assert (!crtl->stack_realign_needed);
/* regparm nested functions don't work with eh_return. */
gcc_assert (!ix86_static_chain_on_stack);
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -march=haswell -mno-avx512f -mtune-ctrl=avx256_move_by_pieces" } */
+/* { dg-options "-O2 -mincoming-stack-boundary=4 -march=haswell -mno-avx512f -mtune-ctrl=avx256_move_by_pieces" } */
struct _Unwind_Context
{
@@ -1,6 +1,6 @@
/* PR target/101772 */
/* { dg-do compile } */
-/* { dg-additional-options "-O0 -march=x86-64 -mstackrealign" } */
+/* { dg-additional-options "-O0 -mincoming-stack-boundary=4 -march=x86-64 -mstackrealign" } */
struct _Unwind_Context _Unwind_Resume_or_Rethrow_this_context;
@@ -1583,3 +1583,16 @@ case ${host} in
tmake_file="$tmake_file t-gthr-noweak"
;;
esac
+
+case ${host} in
+i[34567]86-*-* | x86_64-*-*)
+ if test "${host_address}" = 32; then
+ case ${host} in
+ *-*-cygwin* | *-*-mingw* | *-*-solaris2*)
+ # Disable SSE on unwind-c.c and unwind-dw2.c to avoid stack
+ # realignment with the 4-byte aligned incoming stack.
+ tmake_file="${tmake_file} i386/${host_address}/t-eh-return-no-sse"
+ ;;
+ esac
+ fi
+esac
new file mode 100644
@@ -0,0 +1,5 @@
+# Since eh_return doesn't work with stack realignment, disable SSE on
+# unwind-c.c and unwind-dw2.c to avoid stack realignment with the 4-byte
+# incoming stack.
+
+unwind-c.o unwind-c_s.o unwind-dw2.o unwind-dw2_s.o : HOST_LIBGCC2_CFLAGS += -mno-sse