gcc/gcc12-pr104781.patch

82 lines
2.8 KiB
Diff

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): Sorry if there is
stack realignment with eh_return or regparm nested function.
* config/i386/i386.h (LIBGCC2_UNWIND_ATTRIBUTE): Define.
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.
--- gcc/config/i386/i386.cc
+++ gcc/config/i386/i386.cc
@@ -9444,12 +9444,15 @@ 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. */
+ if (crtl->stack_realign_needed)
+ sorry ("Stack realignment not supported with "
+ "%<__builtin_eh_return%>");
/* regparm nested functions don't work with eh_return. */
- gcc_assert (!ix86_static_chain_on_stack);
+ if (ix86_static_chain_on_stack)
+ sorry ("regparm nested function not supported with "
+ "%<__builtin_eh_return%>");
if (frame_pointer_needed)
{
--- gcc/config/i386/i386.h.jj 2022-02-25 12:06:45.535493490 +0100
+++ gcc/config/i386/i386.h 2022-03-08 11:20:43.207043370 +0100
@@ -2848,6 +2848,12 @@ extern enum attr_cpu ix86_schedule;
#define NUM_X86_64_MS_CLOBBERED_REGS 12
#endif
+/* __builtin_eh_return can't handle stack realignment, so disable SSE in
+ libgcc functions that call it. */
+#ifndef __x86_64__
+#define LIBGCC2_UNWIND_ATTRIBUTE __attribute__((target ("no-sse")))
+#endif
+
/*
Local variables:
version-control: t
--- gcc/testsuite/gcc.target/i386/eh_return-1.c
+++ gcc/testsuite/gcc.target/i386/eh_return-1.c
@@ -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
{
--- gcc/testsuite/gcc.target/i386/eh_return-2.c
+++ gcc/testsuite/gcc.target/i386/eh_return-2.c
@@ -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;