From patchwork Wed Apr 12 17:55:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 97340 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp378085qgf; Wed, 12 Apr 2017 10:56:08 -0700 (PDT) X-Received: by 10.99.115.6 with SMTP id o6mr67693320pgc.216.1492019768330; Wed, 12 Apr 2017 10:56:08 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q23si21208392pfg.5.2017.04.12.10.56.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 10:56:08 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-451494-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; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-451494-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-451494-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=UD5QJeordGdqtpNXGU3j+ru87slAYGDiJVhYyj9B2tzgNL 0nblywS5Ay7hV9UK0QlNEIliTHTGUfbcB89DenVkj+2qJp8fKXVuzyEFBwewYcCN DEXykFlyM0srT7USM/twBG6wlxOPpQwnb5v198LD4P1ZqiuCwi0iTJP+JsTZw= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=F/65iERHqLhzkbV84z9Qjh3E88A=; b=mlSWIuPHuwiCny1MCk7v FhAcXt0HNyJciNMrHcliD5ErrohDIAEwmRmjU3I11a5X0Usst82IBnqemX6nM3Zt 2bNfWSmBgf1vdR6h2qxxz5BXYlL9e5G3F01uJQAoHbPh9LL2ASfLDDvo9kdRYZuJ mTNMvSkXigUpLWHlQOSoIiQ= Received: (qmail 25596 invoked by alias); 12 Apr 2017 17:55:47 -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 25503 invoked by uid 89); 12 Apr 2017 17:55:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-9.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=transfer X-HELO: mail-qk0-f176.google.com Received: from mail-qk0-f176.google.com (HELO mail-qk0-f176.google.com) (209.85.220.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Apr 2017 17:55:45 +0000 Received: by mail-qk0-f176.google.com with SMTP id f133so29784709qke.2 for ; Wed, 12 Apr 2017 10:55:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=8hnDysip444Hia8BcYUUd3EUno38pI7q4b5A7tczkuQ=; b=Lc8//Rdiiv66bVP+iXwoVfmtWG9EX8LbVEteEHfhY8yV3vTAQpV7KwXT3XVAIOoNSC vsVR9/TGe0p8ax42u7Hunp9SfZlCibdfVfYZgaoltu1mHrpg4oIntjD20kIoudPYY2eO rKGVz7PVoC/D5Ey2UhA30Mvqd0qkpdaglzEAH8xhunXFEcF2gEI99rGSDVDLPsrVyj/6 5jIEl5FtLXr9Jrh3yIjP4jZ3fFxd/K9APmyK5fqhBDHUznZuKrpRK1QEgvcvv+Y717cp YOlH8czDjGZpixeLyOdTZHC804PYyEVxie0NchTxhat395fS+EEUSzABT+WU705W5zLW /cZw== X-Gm-Message-State: AFeK/H0glkgQ0l5Ga6GBdOypmx2a8JwIY/chK1PPGmRTHrwnDPTUQq/g0fJaLmhBT2pRCV81deBHWvdciGeJkhUq X-Received: by 10.55.101.213 with SMTP id z204mr41661372qkb.146.1492019744707; Wed, 12 Apr 2017 10:55:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.104.76 with HTTP; Wed, 12 Apr 2017 10:55:44 -0700 (PDT) From: Christophe Lyon Date: Wed, 12 Apr 2017 19:55:44 +0200 Message-ID: Subject: [Patch, GCC/ARM, gcc-5-branch] Fix PR68390 Incorrect code due to indirect tail call of varargs function with hard float ABI To: "gcc-patches@gcc.gnu.org" , Ramana Radhakrishnan X-IsSubscribed: yes Hi, It looks like we forgot to backport the fix for PR68390 to gcc-5-branch. The patch applies cleanly, and fwiw we've had it in the linaro-5 branch for a while. OK to apply to gcc-5-branch? Thanks, Christophe 2017-04-12 Christophe Lyon Backport from mainline +2015-11-23 Kugan Vivekanandarajah gcc/ PR target/68390 * config/arm/arm.c (arm_function_ok_for_sibcall): Get function type for indirect function call. gcc/testsuite/ PR target/68390 * gcc.c-torture/execute/pr68390.c: New test. Index: gcc/config/arm/arm.c =================================================================== --- gcc/config/arm/arm.c (revision 246880) +++ gcc/config/arm/arm.c (working copy) @@ -6507,8 +6507,13 @@ a VFP register but then need to transfer it to a core register. */ rtx a, b; + tree decl_or_type = decl; - a = arm_function_value (TREE_TYPE (exp), decl, false); + /* If it is an indirect function pointer, get the function type. */ + if (!decl) + decl_or_type = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp))); + + a = arm_function_value (TREE_TYPE (exp), decl_or_type, false); b = arm_function_value (TREE_TYPE (DECL_RESULT (cfun->decl)), cfun->decl, false); if (!rtx_equal_p (a, b)) Index: gcc/testsuite/gcc.c-torture/execute/pr68390.c =================================================================== --- gcc/testsuite/gcc.c-torture/execute/pr68390.c (nonexistent) +++ gcc/testsuite/gcc.c-torture/execute/pr68390.c (working copy) @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +__attribute__ ((noinline)) +double direct(int x, ...) +{ + return x*x; +} + +__attribute__ ((noinline)) +double broken(double (*indirect)(int x, ...), int v) +{ + return indirect(v); +} + +int main () +{ + double d1, d2; + int i = 2; + d1 = broken (direct, i); + if (d1 != i*i) + { + __builtin_abort (); + } + return 0; +} +