From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80582 invoked by alias); 12 Jun 2017 10:19:17 -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 79226 invoked by uid 89); 12 Jun 2017 10:19:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:2466, 11,14, 1113 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; Mon, 12 Jun 2017 10:19:14 +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 83BBC2B; Mon, 12 Jun 2017 03:19:16 -0700 (PDT) Received: from [10.2.207.43] (e104453-lin.cambridge.arm.com [10.2.207.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DD6AA3F483; Mon, 12 Jun 2017 03:19:15 -0700 (PDT) Subject: Re: Statically propagate basic blocks which are likely executed 0 times To: Jan Hubicka , Christophe Lyon References: <20170608125249.GB65161@kam.mff.cuni.cz> <4E3B1900-B7BF-4332-B6E4-25FA4BEC81B8@gmail.com> <20170609095435.GD6887@kam.mff.cuni.cz> Cc: "gcc-patches@gcc.gnu.org" From: Renlin Li Message-ID: <593E6AA1.6090900@foss.arm.com> Date: Mon, 12 Jun 2017 10: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: <20170609095435.GD6887@kam.mff.cuni.cz> Content-Type: multipart/mixed; boundary="------------020505000603000005030105" X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00765.txt.bz2 This is a multi-part message in MIME format. --------------020505000603000005030105 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1854 Hi Honza & Christophe, I have tested your suggested fix. It does fix the regression. Here is a simple patch for it. After r249013, die () and dump_stack () are both in cold section. This makes the compiler generate bl instruction for the function call, instead of honoring the -mlong-calls option. This patch changes the dump_stack function call conditional, which fixes the regression. Okay to commit? Regards, Renlin gcc/testsuite/ChangeLog: 2017-06-12 Renlin Li * gcc.target/arm/cold-lc.c: Update coding style, call dump_stack conditionally. On 09/06/17 10:54, Jan Hubicka wrote: >> Since this commit (r249013), I've noticed a regression on arm targets: >> FAIL: gcc.target/arm/cold-lc.c scan-assembler-not bl[^\n]*dump_stack > > I think that is because we optimize the testcase: > /* { dg-do compile } */ > /* { dg-options "-O2 -mlong-calls" } */ > /* { dg-final { scan-assembler-not "bl\[^\n\]*dump_stack" } } */ > > extern void dump_stack (void) __attribute__ ((__cold__)) __attribute__ ((noinline)); > struct thread_info { > struct task_struct *task; > }; > extern struct thread_info *current_thread_info (void); > extern int show_stack (struct task_struct *, unsigned long *); > > void dump_stack (void) > { > unsigned long stack; > show_stack ((current_thread_info ()->task), &stack); > } > > void die (char *str, void *fp, int nr) > { > dump_stack (); > while (1); > } > > the new logic will move die() into cold section (because it unavoidably leads to cold > code and thus allow using the bl instruction. > I guess just modifying die to call dump_stack conditionally should fix the testcase. > > Honza >> >> >>>> + if (!n->analyzed >>>> + || n->decl == current_function_decl) >>>> + return false; >>>> + return n->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED; >>>> +} >>> --------------020505000603000005030105 Content-Type: text/x-patch; name="cold-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cold-1.diff" Content-length: 603 diff --git a/gcc/testsuite/gcc.target/arm/cold-lc.c b/gcc/testsuite/gcc.target/arm/cold-lc.c index 467a696..f0cd6df 100644 --- a/gcc/testsuite/gcc.target/arm/cold-lc.c +++ b/gcc/testsuite/gcc.target/arm/cold-lc.c @@ -11,13 +11,14 @@ extern int show_stack (struct task_struct *, unsigned long *); void dump_stack (void) { - unsigned long stack; - show_stack ((current_thread_info ()->task), &stack); + unsigned long stack; + show_stack ((current_thread_info ()->task), &stack); } void die (char *str, void *fp, int nr) { + if (nr) dump_stack (); - while (1); + while (1); } --------------020505000603000005030105--