]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Do not use %ecx DRAP for functions that use __builtin_eh_return [PR104362]
authorUros Bizjak <ubizjak@gmail.com>
Thu, 3 Feb 2022 21:24:21 +0000 (22:24 +0100)
committerUros Bizjak <ubizjak@gmail.com>
Thu, 3 Feb 2022 21:25:21 +0000 (22:25 +0100)
%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.cc (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.

gcc/config/i386/i386.cc
gcc/testsuite/gcc.target/i386/pr104362.c [new file with mode: 0644]

index ad5a5caa413bd42c48bdab0e90f668fb7b361560..dd5584fb8edfaec3d46a868c6ebc2844e3fccf6e 100644 (file)
@@ -7400,7 +7400,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 (file)
index 0000000..5e5422e
--- /dev/null
@@ -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);
+}