From patchwork Fri Dec 9 17:22:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andre Vieira (lists)" X-Patchwork-Id: 704626 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 3tZzZj03B5z9vFf for ; Sat, 10 Dec 2016 04:22:51 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Ql44MYvY"; 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 :subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=LHnDc4s2oF998SeTx fBHpxQF+N0arfDJqOhJFZmRvLQSSJM9W8B+t2VuHfbIsDjRhKSgvPU02CquqpppD 9kmRJLqR/sr12n6N+1uGg38AKdzCNwHalTQ2O/EeD493jTR4ovTCUfFZWrTcbohU abP7Gr/C2dq9xHO+ISdW5BybcQ= 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:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=B6C6aBGGox+tUbkpXHEbrHO ZUbY=; b=Ql44MYvYS2BU3NiAXrt/OUbQk/E6wNcOXsPq31wdcr1c2Bpjl62oe4t J9CGs40Iqx6mPUb3cZTWl6FP99JlSAl/3DxiKVdf8ZaocsujUowN/QLt1BbmXoG3 Fv7+aeCEgJD8efVgpmggzVrfAU/zxW/vsj0ZpOyCpieQegE0F0Uk= Received: (qmail 44213 invoked by alias); 9 Dec 2016 17:22:43 -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 44199 invoked by uid 89); 9 Dec 2016 17:22:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=BAYES_00, KAM_LOTSOFHASH, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:embedde, Hx-languages-length:4726, H*f:sk:db6385c, H*i:sk:db6385c 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, 09 Dec 2016 17:22:36 +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 58E3DAD7; Fri, 9 Dec 2016 09:22:34 -0800 (PST) Received: from [10.2.206.251] (e107157-lin.cambridge.arm.com [10.2.206.251]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 09DC83F445 for ; Fri, 9 Dec 2016 09:22:33 -0800 (PST) Subject: [arm-embedded][committed] PR78255: Make postreload aware of NO_FUNCTION_CSE To: GCC Patches References: <584AB9AA.6030800@arm.com> <334ff580-3e7d-22fb-83da-da18acd84244@redhat.com> <584ACF02.9070101@arm.com> <584AD8E9.3000406@arm.com> From: "Andre Vieira (lists)" Message-ID: <584AE858.5020706@arm.com> Date: Fri, 9 Dec 2016 17:22:32 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes Hi I backported this patch to the embedded-6-branch in revision r243496. Cheers, Andre gcc/ChangeLog.arm: 2016-12-09 Andre Vieira Backport from mainline 2016-12-09 Andre Vieira PR rtl-optimization/78255 * gcc/postreload.c (reload_cse_simplify): Do not CSE a function if NO_FUNCTION_CSE is true. gcc/testsuite/ChangeLog.arm: 2016-12-09 Andre Vieira Backport from mainline 2016-12-09 Andre Vieira PR rtl-optimization/78255 * gcc.target/aarch64/pr78255.c: New. * gcc.target/arm/pr78255-1.c: New. * gcc.target/arm/pr78255-2.c: New. diff --git a/gcc/ChangeLog.arm b/gcc/ChangeLog.arm index 501388026dc76edb195a783d458d2dab538733f8..3b68af407f78320b465951591c2eba9d27fec944 100644 --- a/gcc/ChangeLog.arm +++ b/gcc/ChangeLog.arm @@ -1,3 +1,12 @@ +2016-12-09 Andre Vieira + + Backport from mainline + 2016-12-09 Andre Vieira + + PR rtl-optimization/78255 + * gcc/postreload.c (reload_cse_simplify): Do not CSE a function if + NO_FUNCTION_CSE is true. + 2016-12-07 Thomas Preud'homme Backport from mainline diff --git a/gcc/postreload.c b/gcc/postreload.c index 61c1ce8028e3d8e6cab44f8f36be31fdc8a58f71..311b83019602dd4aa8289fba776a3f16f4340c6f 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -93,6 +93,11 @@ reload_cse_simplify (rtx_insn *insn, rtx testreg) basic_block insn_bb = BLOCK_FOR_INSN (insn); unsigned insn_bb_succs = EDGE_COUNT (insn_bb->succs); + /* If NO_FUNCTION_CSE has been set by the target, then we should not try + to cse function calls. */ + if (NO_FUNCTION_CSE && CALL_P (insn)) + return false; + if (GET_CODE (body) == SET) { int count = 0; diff --git a/gcc/testsuite/ChangeLog.arm b/gcc/testsuite/ChangeLog.arm index d81eaaf9eed3b63ec6403bf4229bd5e4c343063f..af426611d47fc4d134c699580025ca0c58e8903a 100644 --- a/gcc/testsuite/ChangeLog.arm +++ b/gcc/testsuite/ChangeLog.arm @@ -1,3 +1,13 @@ +2016-12-09 Andre Vieira + + Backport from mainline + 2016-12-09 Andre Vieira + + PR rtl-optimization/78255 + * gcc.target/aarch64/pr78255.c: New. + * gcc.target/arm/pr78255-1.c: New. + * gcc.target/arm/pr78255-2.c: New. + 2016-12-07 Thomas Preud'homme Backport from mainline diff --git a/gcc/testsuite/gcc.target/aarch64/pr78255.c b/gcc/testsuite/gcc.target/aarch64/pr78255.c new file mode 100644 index 0000000000000000000000000000000000000000..b078cf3e1c1c7717c9e227721a367f9846f0c7fe --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr78255.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mcmodel=tiny" } */ + +extern int bar (void *); + +int +foo (void) +{ + return bar ((void *)bar); +} + +/* { dg-final { scan-assembler "b\\s+bar" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pr78255-1.c b/gcc/testsuite/gcc.target/arm/pr78255-1.c new file mode 100644 index 0000000000000000000000000000000000000000..5a696825295d18d09822edfc48f211c5712e95bb --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr78255-1.c @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +#include + +struct table_s + { + void (*fun0) + ( void ); + void (*fun1) + ( void ); + void (*fun2) + ( void ); + void (*fun3) + ( void ); + void (*fun4) + ( void ); + void (*fun5) + ( void ); + void (*fun6) + ( void ); + void (*fun7) + ( void ); + } table; + +void callback0(){__asm("mov r0, r0 \n\t");} +void callback1(){__asm("mov r0, r0 \n\t");} +void callback2(){__asm("mov r0, r0 \n\t");} +void callback3(){__asm("mov r0, r0 \n\t");} +void callback4(){__asm("mov r0, r0 \n\t");} + +void test (void) { + memset(&table, 0, sizeof table); + + asm volatile ("" : : : "r3"); + + table.fun0 = callback0; + table.fun1 = callback1; + table.fun2 = callback2; + table.fun3 = callback3; + table.fun4 = callback4; + table.fun0(); +} + +void foo (void) +{ + __builtin_abort (); +} + +int main (void) +{ + unsigned long p = (unsigned long) &foo; + asm volatile ("mov r3, %0" : : "r" (p)); + test (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/pr78255-2.c b/gcc/testsuite/gcc.target/arm/pr78255-2.c new file mode 100644 index 0000000000000000000000000000000000000000..efa01e750b3962497cccb05ab9862fd3935397a3 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr78255-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern int bar (void *); + +int +foo (void) +{ + return bar ((void*)bar); +} + +/* { dg-final { scan-assembler "b\\s+bar" } } */