From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18630 invoked by alias); 27 Mar 2015 10:06:03 -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 18614 invoked by uid 89); 27 Mar 2015 10:06:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 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; Fri, 27 Mar 2015 10:06:01 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by uk-mta-12.uk.mimecast.lan; Fri, 27 Mar 2015 10:05:58 +0000 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 27 Mar 2015 10:05:57 +0000 Message-ID: <55152B85.6090603@arm.com> Date: Fri, 27 Mar 2015 10:06: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: Honggyu Kim Subject: Re: [PATCH][expr.c] PR 65358 Avoid clobbering partial argument during sibcall References: <550ADF8F.7030300@arm.com> In-Reply-To: <550ADF8F.7030300@arm.com> X-MC-Unique: 3mp7vHL5SXOBnrcqyOedyQ-1 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg01424.txt.bz2 Ping. https://gcc.gnu.org/ml/gcc-patches/2015-03/msg01014.html Thanks, Kyrill On 19/03/15 14:39, Kyrill Tkachov wrote: > Hi all, > > This patch fixes PR 65358. For details look at the excellent write-up > by Honggyu in bugzilla. The problem is that we're trying to pass a struct > partially on the stack and partially in regs during a tail-call optimisat= ion > but the struct we're passing is also a partial incoming arg though the sp= lit > between stack and regs is different from its outgoing usage. > > The emit_push_insn code ends up doing a block move for the on-stack part = but > ends up overwriting the part that needs to be loaded into regs. > My first thought was to just load the regs part first and then do the sta= ck > part but that doesn't work as multiple comments in that function indicate > (the block move being expanded to movmem or other functions being one of = the > reasons). > > My proposed solution is to detect when the overlap happens, find the > overlapping region and load it before the stack pushing into pseudos and > after the stack pushing is done move the overlapping values from the pseu= dos > into the hard argument regs that they're supposed to go. > > That way this new functionality should only ever be triggered when there's > the overlap in this PR (causing wrong-code) and shouldn't affect codegen > anywhere else. > > Bootstrapped and tested on arm-none-linux-gnueabihf, aarch64-none-linux-g= nu > and x86_64-linux-gnu. > > According to the PR this appears at least as far back 4.6 so this isn't a > regression on the release branches, but it is a wrong-code bug. > > I'll let Honggyu upstream the testcase separately > (https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00984.html) After guidance from Jeff, I'll take this testcase in as well if this is=20 approved. > > I'll be testing this on the 4.8 and 4.9 branches. > Thoughts on this approach? > > Thanks, > Kyrill > > 2015-03-19 Kyrylo Tkachov > > PR middle-end/65358 > * expr.c (memory_load_overlap): New function. > (emit_push_insn): When pushing partial args to the stack would > clobber the register part load the overlapping part into a pseudo > and put it into the hard reg after pushing.