From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83449 invoked by alias); 26 Nov 2015 11:02:58 -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 83439 invoked by uid 89); 26 Nov 2015 11:02:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Nov 2015 11:02:55 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-38-Tj0b14DWRhas4o6q0NyauA-1; Thu, 26 Nov 2015 11:02:49 +0000 Received: from [10.2.206.200] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 26 Nov 2015 11:02:47 +0000 Message-ID: <5656E6D7.6040800@arm.com> Date: Thu, 26 Nov 2015 11:12:00 -0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Bernd Schmidt Subject: [PATCH][calls.c][4.9/5 backport] PR rtl-optimization/67226: Take into account pretend_args_size when checking stack offsets for sibcall optimisation X-MC-Unique: Tj0b14DWRhas4o6q0NyauA-1 Content-Type: multipart/mixed; boundary="------------090903070806090406040904" X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg03205.txt.bz2 This is a multi-part message in MIME format. --------------090903070806090406040904 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 1087 Hi all, This is a backport to GCC 4.9 and 5 of the patch at https://gcc.gnu.org/ml/= gcc-patches/2015-11/msg03082.html The only difference with the trunk version is that we perform #ifdef checks= on STACK_GROWS_DOWNWARD because on these branches we have not moved away from conditional compilation of th= ose bits. Bernd approved the backports at https://gcc.gnu.org/ml/gcc-patches/2015-11/= msg03090.html so I'll be committing this to the branches. Bootstrapped and tested on arm, aarch64, x86_64. Confirmed that the testcase fails on all the branches before this patch and= passes with it. Thanks, Kyrill 2015-11-26 Kyrylo Tkachov Bernd Schmidt PR rtl-optimization/67226 * calls.c (store_one_arg): Take into account crtl->args.pretend_args_size when checking for overlap between arg->value and argblock + arg->locate.offset during sibcall optimization. 2015-11-26 Kyrylo Tkachov PR rtl-optimization/67226 * gcc.c-torture/execute/pr67226.c: New test. --------------090903070806090406040904 Content-Type: text/x-patch; name=calls-pretend-back.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="calls-pretend-back.patch" Content-length: 1785 diff --git a/gcc/calls.c b/gcc/calls.c index 0987dd0..ee8ea5f 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -4959,6 +4959,13 @@ store_one_arg (struct arg_data *arg, rtx argblock, i= nt flags, if (XEXP (x, 0) !=3D crtl->args.internal_arg_pointer) i =3D INTVAL (XEXP (XEXP (x, 0), 1)); =20 + /* arg.locate doesn't contain the pretend_args_size offset, + it's part of argblock. Ensure we don't count it in I. */ +#ifdef STACK_GROWS_DOWNWARD + i -=3D crtl->args.pretend_args_size; +#else + i +=3D crtl->args.pretend_args_size; +#endif /* expand_call should ensure this. */ gcc_assert (!arg->locate.offset.var && arg->locate.size.var =3D=3D 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr67226.c b/gcc/testsuite/= gcc.c-torture/execute/pr67226.c new file mode 100644 index 0000000..c533496 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr67226.c @@ -0,0 +1,42 @@ +struct assembly_operand +{ + int type, value, symtype, symflags, marker; +}; + +struct assembly_operand to_input, from_input; + +void __attribute__ ((__noinline__, __noclone__)) +assemblez_1 (int internal_number, struct assembly_operand o1) +{ + if (o1.type !=3D from_input.type) + __builtin_abort (); +} + +void __attribute__ ((__noinline__, __noclone__)) +t0 (struct assembly_operand to, struct assembly_operand from) +{ + if (to.value =3D=3D 0) + assemblez_1 (32, from); + else + __builtin_abort (); +} + +int +main (void) +{ + to_input.value =3D 0; + to_input.type =3D 1; + to_input.symtype =3D 2; + to_input.symflags =3D 3; + to_input.marker =3D 4; + + from_input.value =3D 5; + from_input.type =3D 6; + from_input.symtype =3D 7; + from_input.symflags =3D 8; + from_input.marker =3D 9; + + t0 (to_input, from_input); + + return 0; +} --------------090903070806090406040904--