From patchwork Fri Aug 26 08:52:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 663010 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sLFFL6vhQz9sBf for ; Fri, 26 Aug 2016 18:53:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Oa/vGKSM; dkim-atps=neutral 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=kJC+C0OYd+839IXncUstP6U2hQ/RlkK2Ibv35lRiHh8 YIoHYLT7Zjn0iQwFS6oQEdF84ClalDoTJ2tw+7VSY/wPxWnbNlwbECH1ku5WtLff 96Bolmcyta4/1j1RZyLggNn351nSuJTdsgP/nm1CbSZIAo1oGUIEUEO7J/rZ3vj4 = 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=srZ6vJ2/ULv5rFueoWTcqGvCikA=; b=Oa/vGKSM/ajQ6WfVs cx4rm1jvnO2m/ICV5XwBS4kg3n4zJIVCTRiVqad5eEERGEReNhpsaG7dFoAV4vIu uprxdbHtHIFfttF/LINNQDFEYQd1jPfnPCOmHLXSIzfecRggbcRrqqoNW7vU/6j9 puNhd+HmdjTjz6BsXLpjfsUK70= Received: (qmail 103083 invoked by alias); 26 Aug 2016 08:53:09 -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 102978 invoked by uid 89); 26 Aug 2016 08:53:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=2016-08-26, 20160826 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; Fri, 26 Aug 2016 08:52:58 +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 4341D28; Fri, 26 Aug 2016 01:54:36 -0700 (PDT) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2E5D03F32C; Fri, 26 Aug 2016 01:52:54 -0700 (PDT) Message-ID: <57C00364.3020504@foss.arm.com> Date: Fri, 26 Aug 2016 09:52:52 +0100 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: Richard Earnshaw , Marcus Shawcroft , James Greenhalgh , Renlin Li , Andrew Pinski Subject: [PATCH][AArch64][GCC 5] Backport Work around for PR target/64971 Hi all, I'd like to backport this fix for an ILP32 ICE. This was a simple band-aid proposed by Andrew that is self-contained and doesn't touch non-ILP32 or non-aarch64 code so it should be pretty safe to backport. It has been in trunk and GCC 6 for quite some time without issues until Renlin's patch at r235282 fixed the midend issue [1]. Bootstrapped and tested on GCC 5 on aarch64-none-linux-gnu. Is this patch ok for the branch? Thanks, Kyrill [1] https://gcc.gnu.org/ml/gcc-patches/2016-08/msg00332.html 2016-08-26 Kyrylo Tkachov Backport from mainline 2016-04-20 Andrew Pinski Kyrylo Tkachov PR target/64971 * config/aarch64/aarch64.md (sibcall): Force call address to be DImode for ILP32. (sibcall_value): Likewise. PR target/64971 * gcc.c-torture/compile/pr37433 -1.c: New testcase. diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 116fd89102c98c5e1816998ce56cbc4d87525e97..501ae4481451b1730233eb4dfaca2a66a5b1c2ae 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -687,6 +687,13 @@ (define_expand "sibcall" && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF)) XEXP (operands[0], 0) = force_reg (Pmode, XEXP (operands[0], 0)); + /* This is a band-aid. An SImode symbol reference is sometimes generated + by expand_expr_addr_expr. See PR 64971. */ + if (TARGET_ILP32 + && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF + && GET_MODE (XEXP (operands[0], 0)) == SImode) + XEXP (operands[0], 0) = convert_memory_address (Pmode, + XEXP (operands[0], 0)); if (operands[2] == NULL_RTX) operands[2] = const0_rtx; @@ -717,6 +724,14 @@ (define_expand "sibcall_value" && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF)) XEXP (operands[1], 0) = force_reg (Pmode, XEXP (operands[1], 0)); + /* This is a band-aid. An SImode symbol reference is sometimes generated + by expand_expr_addr_expr. See PR 64971. */ + if (TARGET_ILP32 + && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF + && GET_MODE (XEXP (operands[1], 0)) == SImode) + XEXP (operands[1], 0) = convert_memory_address (Pmode, + XEXP (operands[1], 0)); + if (operands[3] == NULL_RTX) operands[3] = const0_rtx; diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c b/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c new file mode 100644 index 0000000000000000000000000000000000000000..c69e9692eb0229154676fc088c41741fa30f1871 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c @@ -0,0 +1,13 @@ +void +regex_subst (void) +{ + const void *subst = ""; + (*(void (*)(int))subst) (0); +} + +void +foobar (void) +{ + int x; + (*(void (*)(void))&x) (); +}