From patchwork Tue Nov 17 02:38:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 56700 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1673048lbb; Mon, 16 Nov 2015 18:39:12 -0800 (PST) X-Received: by 10.68.65.74 with SMTP id v10mr59406556pbs.67.1447727952575; Mon, 16 Nov 2015 18:39:12 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id fn10si54160251pab.4.2015.11.16.18.39.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 18:39:12 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-414312-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-414312-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-414312-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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=f497O8RHRHwG5rFx+4GY2thkYFlYT0jzaGYAwWSknH61mCCnVxGtT sZbpbqVPPCQelRhDq0wBwxawXs0L3raVlw4om171NtO1t+bs5moixKbmXlGPr1ae voWhYEdAAehvXk9oKqeep3mLU9EYuzKaRCH1UtjnHljUIVi5CrIAWQ= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=default; bh=IFOPzONpjdPimJy/o4m/5+uvhRc=; b=j/Oawm9NTILTd/KSdf+OMkGh+6C6 V5psjxhXhw6eELcA73JdulCku/OU938VAuvzSKemVwNMgFD7CY9F8zcrNgM5UqNy f09zx8h8eczgC5jej4PZz+bHcl+NtIu3EdzFlsKvoPTKMS1Lt/CpQuLQBnAdNtGp bvLE6y7LAM32Zfs= Received: (qmail 128055 invoked by alias); 17 Nov 2015 02:38:56 -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 128039 invoked by uid 89); 17 Nov 2015 02:38:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f43.google.com Received: from mail-pa0-f43.google.com (HELO mail-pa0-f43.google.com) (209.85.220.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 17 Nov 2015 02:38:54 +0000 Received: by pacdm15 with SMTP id dm15so194764385pac.3 for ; Mon, 16 Nov 2015 18:38:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=cwlUJixV5Ic63QRr7x+Wme4F736XX+8HV3T0JiIKpx8=; b=TLUnYXpo69g23hsabrHAQZV8ORRC1eRHeGz2cMoq3d5N9mGKiaPcM+fsrjo7L7Ghdx lw8XM5diKTh7Yu4aXjfhw+HZHep6WVZsJ4BHCu64qu/BmR6RrPC9ji7lSQir3R8Aiu4D 59kGUI1EF1I8ISo/x4KXK50Z1lnHZY5JNxWyUd7kDPs97rpKq269LGpSJAZ2c6+djyj5 YOFfIvG0sMNpGT9l7EDAnmV3K1b7KrnPPzXFsutvj55MxVh8feaE0G6vRT7f9OJSI27y olAO/Jo4A10PeqON1iODbGYhVyVUHD88/dRyti64nNgpYci79S3UQj0w3RAPKXvo1gHH kxYQ== X-Gm-Message-State: ALoCoQmSF2PPLfjgZbRFLxk8ljuU//SK5HDy+4y1q6EOI+t5RWfAykkze9KDq2ImuxoxP2Zkz0Ni X-Received: by 10.66.122.67 with SMTP id lq3mr22344012pab.21.1447727932211; Mon, 16 Nov 2015 18:38:52 -0800 (PST) Received: from [10.1.1.10] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.googlemail.com with ESMTPSA id we9sm39217268pab.3.2015.11.16.18.38.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 18:38:50 -0800 (PST) Subject: Re: Incorrect code due to indirect tail call of varargs function with hard float ABI To: Charles Baylis References: <564A57BA.7050504@linaro.org> Cc: "gcc-patches@gcc.gnu.org" , Richard Earnshaw , Ramana Radhakrishnan , Kyrill Tkachov From: Kugan Message-ID: <564A9327.8070607@linaro.org> Date: Tue, 17 Nov 2015 13:38:31 +1100 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: X-IsSubscribed: yes On 17/11/15 12:00, Charles Baylis wrote: > On 16 November 2015 at 22:24, Kugan wrote: > >> Please note that we have a sibcall from "broken" to "indirect". >> >> "direct" is variadic function so it is conforming to AAPCS base standard. >> >> "broken" is a non-variadic function and will return the value in >> floating point register for TARGET_HARD_FLOAT. Thus we should not be >> doing sibcall here. >> >> Attached patch fixes this. Bootstrap and regression testing is ongoing. >> Is this OK if no issues with the testing? > > Hi Kugan, > > It looks like this patch should work, but I think this is an overly > conservative fix, as it prevents all sibcalls for hardfloat targets. > It would be better if only variadic sibcalls were prevented on > hardfloat. You can check for variadic calls by checking the > function_type in the call expression (exp) using stdarg_p(). > > As an example to show how to test for variadic function calls, this is > how to test it in gdb: > > (gdb) b arm_function_ok_for_sibcall > Breakpoint 1 at 0xdae59c: file > /home/cbaylis/srcarea/gcc/gcc-git/gcc/config/arm/arm.c, line 6634. > (gdb) r > ... > Breakpoint 1, arm_function_ok_for_sibcall (decl=0x0, exp=0x7ffff6104ce8) > at /home/cbaylis/srcarea/gcc/gcc-git/gcc/config/arm/arm.c:6634 > 6634 if (cfun->machine->sibcall_blocked) > (gdb) print debug_tree(exp) > type size > unit size > align 64 symtab 0 alias set -1 canonical type 0x7ffff62835e8 > precision 64 > pointer_to_this > > side-effects addressable > fn type > ... > (gdb) print stdarg_p((tree)0x7ffff60e9348) <--- from function_type ^^^^^ > $2 = true > How about: Thanks, Kugan diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index a379121..2376d66 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -6681,6 +6681,13 @@ arm_function_ok_for_sibcall (tree decl, tree exp) register. */ rtx a, b; + /* If it is an indirect function pointer, get the function type. */ + if (!decl + && POINTER_TYPE_P (TREE_TYPE (CALL_EXPR_FN (exp))) + && (TREE_CODE (TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp)))) + == FUNCTION_TYPE)) + decl = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp))); + a = arm_function_value (TREE_TYPE (exp), decl, false); b = arm_function_value (TREE_TYPE (DECL_RESULT (cfun->decl)), cfun->decl, false);