From: Renlin Li <renlin.li@foss.arm.com>
To: Jan Hubicka <hubicka@ucw.cz>,
Christophe Lyon <christophe.lyon@linaro.org>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: Statically propagate basic blocks which are likely executed 0 times
Date: Mon, 12 Jun 2017 10:19:00 -0000 [thread overview]
Message-ID: <593E6AA1.6090900@foss.arm.com> (raw)
In-Reply-To: <20170609095435.GD6887@kam.mff.cuni.cz>
[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]
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 <renlin.li@arm.com>
* 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;
>>>> +}
>>>
[-- Attachment #2: cold-1.diff --]
[-- Type: text/x-patch, Size: 603 bytes --]
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);
}
next prev parent reply other threads:[~2017-06-12 10:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-08 12:52 Jan Hubicka
2017-06-09 6:43 ` Bernhard Reutner-Fischer
2017-06-09 9:04 ` Christophe Lyon
2017-06-09 9:54 ` Jan Hubicka
2017-06-12 10:19 ` Renlin Li [this message]
2017-06-12 10:36 ` Jan Hubicka
2017-06-09 18:35 ` Jan Hubicka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=593E6AA1.6090900@foss.arm.com \
--to=renlin.li@foss.arm.com \
--cc=christophe.lyon@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).