public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Uros Bizjak <uros@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-9537] i386: Do not use %ecx DRAP for functions that use __builtin_eh_return [PR104362]
Date: Thu,  3 Feb 2022 23:23:08 +0000 (GMT)	[thread overview]
Message-ID: <20220203232308.6AC2B3858D37@sourceware.org> (raw)

https://gcc.gnu.org/g:731f4bf14fc89a595abb780a969d03e82b807763

commit r11-9537-g731f4bf14fc89a595abb780a969d03e82b807763
Author: Uros Bizjak <ubizjak@gmail.com>
Date:   Fri Feb 4 00:21:11 2022 +0100

    i386: Do not use %ecx DRAP for functions that use __builtin_eh_return [PR104362]
    
    %ecx can't be used for both DRAP register and eh_return.  Adjust find_drap_reg
    to choose %edi for functions that uses __builtin_eh_return to avoid the assert
    in ix86_expand_epilogue that enforces this rule.
    
    2022-02-03  Uroš Bizjak  <ubizjak@gmail.com>
    
    gcc/ChangeLog:
    
            PR target/104362
            * config/i386/i386.c (find_drap_reg): For 32bit targets
            return DI_REG if function uses __builtin_eh_return.
    
    gcc/testsuite/ChangeLog:
    
            PR target/104362
            * gcc.target/i386/pr104362.c: New test.

Diff:
---
 gcc/config/i386/i386.c                   |  3 ++-
 gcc/testsuite/gcc.target/i386/pr104362.c | 24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 8e8c8beb366..bf471735d58 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7219,7 +7219,8 @@ find_drap_reg (void)
 	 register in such case.  */
       if (DECL_STATIC_CHAIN (decl)
 	  || cfun->machine->no_caller_saved_registers
-	  || crtl->tail_call_emit)
+	  || crtl->tail_call_emit
+	  || crtl->calls_eh_return)
 	return DI_REG;
 
       /* Reuse static chain register if it isn't used for parameter
diff --git a/gcc/testsuite/gcc.target/i386/pr104362.c b/gcc/testsuite/gcc.target/i386/pr104362.c
new file mode 100644
index 00000000000..5e5422e2679
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr104362.c
@@ -0,0 +1,24 @@
+/* PR target/104362 */
+/* { dg-do compile } */
+/* { dg-options "-mavx512f" } */
+
+struct _Unwind_Context
+{
+  void *ra;
+  char array[48];
+};
+
+extern long uw_install_context_1 (struct _Unwind_Context *);
+
+void
+_Unwind_RaiseException (void)
+{
+  struct _Unwind_Context this_context, cur_context;
+  __builtin_memset(&this_context, 55, sizeof(this_context));
+  long offset = uw_install_context_1 (&this_context);
+  __builtin_memcpy (&this_context, &cur_context,
+                    sizeof (struct _Unwind_Context));
+  void *handler = __builtin_frob_return_addr ((&cur_context)->ra);
+  uw_install_context_1 (&cur_context);
+  __builtin_eh_return (offset, handler);
+}


                 reply	other threads:[~2022-02-03 23:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220203232308.6AC2B3858D37@sourceware.org \
    --to=uros@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).