From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114877 invoked by alias); 5 Feb 2020 13:53:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 114801 invoked by uid 89); 5 Feb 2020 13:53:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=church, Church X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Feb 2020 13:53:35 +0000 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 015Dms17022346 for ; Wed, 5 Feb 2020 08:53:34 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xyhpxs0qg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 05 Feb 2020 08:53:33 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 5 Feb 2020 13:53:31 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 5 Feb 2020 13:53:30 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 015DrTcT53739650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Feb 2020 13:53:29 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1FC3311C04C; Wed, 5 Feb 2020 13:53:29 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5620811C05B; Wed, 5 Feb 2020 13:53:28 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 5 Feb 2020 13:53:28 +0000 (GMT) From: Jiufu Guo To: gcc-patches@gcc.gnu.org Cc: guojiufu@linux.ibm.com, wschmidt@linux.ibm.com, segher@kernel.crashing.org Subject: [PATCH, rs6000]: mark clobber for registers changed by untpyed_call Date: Wed, 05 Feb 2020 13:53:00 -0000 x-cbid: 20020513-0016-0000-0000-000002E3EB79 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020513-0017-0000-0000-00003346CC13 Message-Id: <1580910807-24635-1-git-send-email-guojiufu@linux.ibm.com> X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00263.txt.bz2 As PR93047 said, __builtin_apply/__builtin_return does not work well with -frename-registers. This is caused by return register(e.g. r3) is used to rename another register, before return register is stored to stack. This patch fix this issue by emitting clobber for those egisters which maybe changed by untyped call. Because this would be a kind of wrong code, so I'm thinking to submit to gcc10. Bootstrap and regtest on powerpc64le are pass. Is this okay for trunk? Thanks, Jiufu gcc/ 2020-02-05 Jiufu Guo PR target/93047 * config/rs6000/rs6000.md (untyped_call): add emit_clobber. gcc/testsuite 2020-02-05 Jiufu Guo PR target/93047 * gcc.dg/torture/stackalign/builtin-return-2.c: New case. diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index f3c8eb0..d68bc24 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -10867,6 +10867,9 @@ emit_call_insn (gen_call (operands[0], const0_rtx, const0_rtx)); + for (int i = 0; i < XVECLEN (operands[2], 0); i++) + emit_clobber (SET_SRC (XVECEXP (operands[2], 0, i))); + for (i = 0; i < XVECLEN (operands[2], 0); i++) { rtx set = XVECEXP (operands[2], 0, i); diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-2.c new file mode 100644 index 0000000..7719109 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-return-2.c @@ -0,0 +1,40 @@ +/* PR target/93047 */ +/* Originator: Andrew Church */ +/* { dg-do run } */ +/* { dg-additional-options "-O3 -frename-registers" } */ +/* { dg-require-effective-target untyped_assembly } */ + +#ifdef __MMIX__ +/* No parameters on stack for bar. */ +#define STACK_ARGUMENTS_SIZE 0 +#else +#define STACK_ARGUMENTS_SIZE 64 +#endif + +extern void abort(void); + +int foo(int n) +{ + return n+1; +} + +int bar(int n) +{ + __builtin_return(__builtin_apply((void (*)(void))foo, __builtin_apply_args(), + STACK_ARGUMENTS_SIZE)); +} + +int main(void) +{ + /* Allocate 64 bytes on the stack to make sure that __builtin_apply + can read at least 64 bytes above the return address. */ + char dummy[64]; + + __asm__ ("" : : "" (dummy)); + + if (bar(1) != 2) + abort(); + + return 0; +} +