From patchwork Thu Nov 26 11:02:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrylo Tkachov X-Patchwork-Id: 57324 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp441425lbb; Thu, 26 Nov 2015 03:03:09 -0800 (PST) X-Received: by 10.66.124.165 with SMTP id mj5mr57962443pab.97.1448535789411; Thu, 26 Nov 2015 03:03:09 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h9si8083721pat.117.2015.11.26.03.03.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Nov 2015 03:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-415489-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-return-415489-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-415489-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=f4F4+ICUHIkHIRsyfSXSC/9WdC0gEaxpwFWUYivEUeb pPHXqGRurrqQcSnYAj0A53phwbInZB+4HCE1Ev4H2rRPHFPsfFkUSdTnzDXm0idM kX6izoBj/khpnYfTFOayQ/Pyn6TZmJHY8dzJkQ8a6X8grd4E+T2FR496mGqhQh0o = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=lZl8hBmG6wlfLnbTNs6ZWGdGDis=; b=kK9uSXte6ZUf+RDai yDy4DwaSBY+KBBYkRJK3rjIh1aaULDY95bhmtQtRau/yBPmXOs6bcSxth/rSZq36 +GZ/5II/9Na4+S4H7qr/ntfomQ89eUu47U6UcLSV94Epv9S0WzuWaH798h9PNOLk ujMg1UyAuTyaa0rL8Z7ev9VANU= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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:02:47 +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 X-IsSubscribed: yes 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 those 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. 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, int flags, if (XEXP (x, 0) != crtl->args.internal_arg_pointer) i = INTVAL (XEXP (XEXP (x, 0), 1)); + /* 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 -= crtl->args.pretend_args_size; +#else + i += crtl->args.pretend_args_size; +#endif /* expand_call should ensure this. */ gcc_assert (!arg->locate.offset.var && arg->locate.size.var == 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 != from_input.type) + __builtin_abort (); +} + +void __attribute__ ((__noinline__, __noclone__)) +t0 (struct assembly_operand to, struct assembly_operand from) +{ + if (to.value == 0) + assemblez_1 (32, from); + else + __builtin_abort (); +} + +int +main (void) +{ + to_input.value = 0; + to_input.type = 1; + to_input.symtype = 2; + to_input.symflags = 3; + to_input.marker = 4; + + from_input.value = 5; + from_input.type = 6; + from_input.symtype = 7; + from_input.symflags = 8; + from_input.marker = 9; + + t0 (to_input, from_input); + + return 0; +}