From: Richard Sandiford <richard.sandiford@linaro.org>
To: Arjan van de Ven <arjan@linux.intel.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
"H.J. Lu" <hjl.tools@gmail.com>,
Alexander Monakov <amonakov@ispras.ru>,
Michael Matz <matz@suse.de>, Uros Bizjak <ubizjak@gmail.com>,
"gcc-patches\@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] i386: Don't use frame pointer without stack access
Date: Mon, 07 Aug 2017 20:05:00 -0000 [thread overview]
Message-ID: <878tivdtz9.fsf@linaro.org> (raw)
In-Reply-To: <9c734d2b-7ba2-057b-7505-a7b300cde472@linux.intel.com> (Arjan van de Ven's message of "Mon, 7 Aug 2017 09:06:05 -0700")
Arjan van de Ven <arjan@linux.intel.com> writes:
> On 8/7/2017 8:43 AM, Jakub Jelinek wrote:
>> On Mon, Aug 07, 2017 at 08:39:24AM -0700, H.J. Lu wrote:
>>> When Linux/x86-64 kernel is compiled with -fno-omit-frame-pointer.
>>> this optimization removes more than 730
>>>
>>> pushq %rbp
>>> movq %rsp, %rbp
>>> popq %rbp
>>
>> If you don't want the frame pointer, why are you compiling with
>> -fno-omit-frame-pointer? Are you going to add
>> -fforce-no-omit-frame-pointer or something similar so that people can
>> actually get what they are asking for? This doesn't really make sense.
>> It is perfectly fine to omit frame pointer by default, when it isn't
>> required for something, but if the user asks for it, we shouldn't ignore his
>> request.
>>
>
>
> wanting a framepointer is very nice and desired... ... but if the
> optimizer/ins scheduler moves instructions outside of the frame'd
> portion, (it does it for cases like below as well), the value is
> already negative for these functions that don't have stack use.
>
> <MPIDU_Sched_are_pending@@Base>:
> mov all_schedules@@Base-0x38460,%rax
> push %rbp
> mov %rsp,%rbp
> pop %rbp
> cmpq $0x0,(%rax)
> setne %al
> movzbl %al,%eax
> retq
Yeah, and it could be even weirder for big single-block functions.
I think GCC has been doing this kind of scheduling of prologue and
epilogue instructions for a while, so there hasn*t really been a
guarantee which parts of the function will have a new FP and which
will still have the old one.
Also, with an arbitrarily-picked host compiler (GCC 6.3.1), shrink-wrapping
kicks in when the following is compiled with -O3 -fno-omit-frame-pointer:
void f (int *);
void
g (int *x)
{
for (int i = 0; i < 1000; ++i)
x[i] += 1;
if (x[0])
{
int temp;
f (&temp);
}
}
so only the block with the call to f sets up FP. The relatively
long-running loop runs with the caller's FP.
I hope we can go for a target-independent position that what HJ*s
patch does is OK...
Thanks,
Richard
next prev parent reply other threads:[~2017-08-07 20:05 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-06 19:40 H.J. Lu
2017-08-07 6:21 ` Uros Bizjak
2017-08-07 13:15 ` Michael Matz
2017-08-07 13:21 ` Uros Bizjak
2017-08-07 13:25 ` H.J. Lu
2017-08-07 13:32 ` Michael Matz
2017-08-07 13:38 ` H.J. Lu
2017-08-07 13:49 ` Michael Matz
2017-08-07 14:06 ` Alexander Monakov
2017-08-07 15:39 ` H.J. Lu
2017-08-07 15:43 ` Jakub Jelinek
2017-08-07 16:06 ` Arjan van de Ven
2017-08-07 16:16 ` Michael Matz
2017-08-07 16:19 ` Arjan van de Ven
2017-08-07 16:21 ` H.J. Lu
2017-08-07 16:28 ` Michael Matz
2017-08-07 20:05 ` Richard Sandiford [this message]
2017-08-08 16:38 ` H.J. Lu
2017-08-08 17:01 ` Richard Biener
2017-08-08 17:34 ` Richard Sandiford
2017-08-08 17:36 ` Richard Sandiford
2017-08-08 18:00 ` Richard Biener
2017-08-08 18:29 ` H.J. Lu
2017-08-09 7:53 ` Richard Sandiford
2017-08-09 11:22 ` Richard Biener
2017-08-09 11:31 ` H.J. Lu
2017-08-09 11:59 ` Michael Matz
2017-08-09 12:27 ` H.J. Lu
2017-08-09 15:04 ` Andi Kleen
2017-08-09 15:05 ` Arjan van de Ven
2017-08-09 15:14 ` H.J. Lu
2017-08-09 15:26 ` Andi Kleen
2017-08-09 17:28 ` H.J. Lu
2017-08-09 18:31 ` H.J. Lu
2017-08-10 7:19 ` Richard Sandiford
2017-08-10 7:40 ` Richard Sandiford
2017-08-10 7:51 ` Uros Bizjak
2017-08-10 14:07 ` H.J. Lu
2017-08-08 17:05 ` Uros Bizjak
2017-08-07 18:40 ` Uros Bizjak
2017-08-07 13:38 ` Andreas Schwab
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=878tivdtz9.fsf@linaro.org \
--to=richard.sandiford@linaro.org \
--cc=amonakov@ispras.ru \
--cc=arjan@linux.intel.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
--cc=jakub@redhat.com \
--cc=matz@suse.de \
--cc=ubizjak@gmail.com \
/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).