From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 43944 invoked by alias); 18 Nov 2015 09:19: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 43928 invoked by uid 89); 18 Nov 2015 09:19:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Nov 2015 09:19:56 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E383D49; Wed, 18 Nov 2015 01:19:38 -0800 (PST) Received: from [10.2.206.27] (e105545-lin.cambridge.arm.com [10.2.206.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 804CC3F213; Wed, 18 Nov 2015 01:19:52 -0800 (PST) Subject: Re: Incorrect code due to indirect tail call of varargs function with hard float ABI To: Kugan , Ramana Radhakrishnan , Charles Baylis References: <564A57BA.7050504@linaro.org> <564A9327.8070607@linaro.org> <564AFBEE.9050801@foss.arm.com> <564B8655.1060509@linaro.org> <564BC70C.70805@linaro.org> Cc: "gcc-patches@gcc.gnu.org" , Richard Earnshaw , Kyrill Tkachov From: Ramana Radhakrishnan Message-ID: <564C42B7.9040702@foss.arm.com> Date: Wed, 18 Nov 2015 09:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <564BC70C.70805@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-11/txt/msg02172.txt.bz2 On 18/11/15 00:32, Kugan wrote: >> > Hi Ramana, >> > >> > Thanks for the review. I have opened a gcc bug-report for this. I tested >> > the attached patch for arm-none-linux-gnueabihf and >> > arm-none-linux-gnueabi with no new regressions. Is this OK? >> > >> > >> > Thanks, >> > Kugan >> > >> > gcc/ChangeLog: >> > >> > 2015-11-18 Kugan Vivekanandarajah >> > >> > PR target/68390 >> > * config/arm/arm.c (arm_function_ok_for_sibcall): Get function type >> > for indirect function call. >> > >> > gcc/testsuite/ChangeLog: >> > >> > 2015-11-18 Kugan Vivekanandarajah >> > >> > PR target/68390 >> > * gcc.target/arm/PR68390.c: New test. >> > >> > > Hi Ramana, > > With further testing on bare-metal, I found that for the following decl > has to be null for indirect functions. > > if (TARGET_AAPCS_BASED > && arm_abi == ARM_ABI_AAPCS > && decl > && DECL_WEAK (decl)) > return false; Ok .. yes that's right. > > Here is the updated patch and ChangeLog. Sorry for the noise. > > Thanks, > Kugan > > > gcc/ChangeLog: > > 2015-11-18 Kugan Vivekanandarajah > > PR target/68390 > * config/arm/arm.c (arm_function_ok_for_sibcall): Get function type > for indirect function call. > > gcc/testsuite/ChangeLog: > > 2015-11-18 Kugan Vivekanandarajah > > PR target/68390 > * gcc.target/arm/PR68390.c: New test. > s/PR/pr in the test name and put this in gcc.c-torture/execute instead - there is nothing ARM specific about the test. Tests in gcc.target/arm should really only be architecture specific. This isn't. > > > > p.txt > > > diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c > index a379121..0dae7da 100644 > --- a/gcc/config/arm/arm.c > +++ b/gcc/config/arm/arm.c > @@ -6680,8 +6680,13 @@ arm_function_ok_for_sibcall (tree decl, tree exp) > a VFP register but then need to transfer it to a core > register. */ > rtx a, b; > + tree fn_decl = decl; Call it decl_or_type instead - it's really that ... > > - a = arm_function_value (TREE_TYPE (exp), decl, false); > + /* If it is an indirect function pointer, get the function type. */ > + if (!decl) > + fn_decl = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp))); > + This is probably just my mail client - but please watch out for indentation. > + a = arm_function_value (TREE_TYPE (exp), fn_decl, false); > b = arm_function_value (TREE_TYPE (DECL_RESULT (cfun->decl)), > cfun->decl, false); > if (!rtx_equal_p (a, b)) OK with those changes. Ramana