From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1363) id 2D14E3858D37; Thu, 3 Feb 2022 21:25:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D14E3858D37 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Uros Bizjak To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7037] i386: Do not use %ecx DRAP for functions that use __builtin_eh_return [PR104362] X-Act-Checkin: gcc X-Git-Author: Uros Bizjak X-Git-Refname: refs/heads/master X-Git-Oldrev: 30d15b512e375dee1b288d66c398513b8cb3e2aa X-Git-Newrev: 599122fa690d55e5e14d74f4d514b2d8b6a98505 Message-Id: <20220203212536.2D14E3858D37@sourceware.org> Date: Thu, 3 Feb 2022 21:25:36 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Feb 2022 21:25:36 -0000 https://gcc.gnu.org/g:599122fa690d55e5e14d74f4d514b2d8b6a98505 commit r12-7037-g599122fa690d55e5e14d74f4d514b2d8b6a98505 Author: Uros Bizjak Date: Thu Feb 3 22:24:21 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 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. Diff: --- gcc/config/i386/i386.cc | 3 ++- gcc/testsuite/gcc.target/i386/pr104362.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index ad5a5caa413..dd5584fb8ed 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -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 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); +}