From: "H.J. Lu" <hjl.tools@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Uros Bizjak <ubizjak@gmail.com>,
Eric Botcazou <ebotcazou@adacore.com>,
Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH v3] x86: Disable SSE on unwind-c.c and unwind-dw2.c
Date: Mon, 7 Mar 2022 07:06:28 -0800 [thread overview]
Message-ID: <20220307150628.68146-1-hjl.tools@gmail.com> (raw)
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.
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 | 11 +++++++----
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, 27 insertions(+), 6 deletions(-)
create mode 100644 libgcc/config/i386/32/t-eh-return-no-sse
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index efa947f9795..4121f986221 100644
--- a/gcc/config/i386/i386.cc
+++ b/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)
{
diff --git a/gcc/testsuite/gcc.target/i386/eh_return-1.c b/gcc/testsuite/gcc.target/i386/eh_return-1.c
index b21fd75fc93..43f94f01a97 100644
--- a/gcc/testsuite/gcc.target/i386/eh_return-1.c
+++ b/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
{
diff --git a/gcc/testsuite/gcc.target/i386/eh_return-2.c b/gcc/testsuite/gcc.target/i386/eh_return-2.c
index f23f4492dac..cb762f92cc2 100644
--- a/gcc/testsuite/gcc.target/i386/eh_return-2.c
+++ b/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;
diff --git a/libgcc/config.host b/libgcc/config.host
index 094fd3ad254..1588ab6cf20 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -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
diff --git a/libgcc/config/i386/32/t-eh-return-no-sse b/libgcc/config/i386/32/t-eh-return-no-sse
new file mode 100644
index 00000000000..5a8c3135911
--- /dev/null
+++ b/libgcc/config/i386/32/t-eh-return-no-sse
@@ -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
--
2.35.1
next reply other threads:[~2022-03-07 15:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 15:06 H.J. Lu [this message]
2022-03-08 10:23 ` Jakub Jelinek
2022-03-08 11:15 ` Jakub Jelinek
2022-03-08 12:29 ` Jakub Jelinek
2022-03-08 12:49 ` Eric Botcazou
2022-03-08 15:37 ` H.J. Lu
2022-03-08 15:46 ` Jakub Jelinek
2022-03-08 16:09 ` H.J. Lu
2022-03-08 17:35 ` [PATCH] x86: Define LIBGCC2_UNWIND_ATTRIBUTE on ia32 [PR104781] Jakub Jelinek
2022-03-08 17:49 ` H.J. Lu
2022-03-09 7:18 ` Richard Biener
2022-03-09 9:59 ` [PATCH] x86, v2: " Jakub Jelinek
2022-03-09 11:30 ` Richard Biener
2022-03-08 17:50 ` [PATCH] x86: " H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220307150628.68146-1-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=ubizjak@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).