From: Iain Sandoe <iain@codesourcery.com>
To: Martin Sebor <msebor@redhat.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
Gcc Patch List <gcc-patches@gcc.gnu.org>, <anton@samba.org>
Subject: Re: [PATCH] pr 63354 - gcc -pg -mprofile-kernel creates unused stack frames on leaf functions on ppc64le
Date: Sat, 21 Mar 2015 19:48:00 -0000 [thread overview]
Message-ID: <210B149C-A8AB-4A0C-98AA-90D72741A7AF@codesourcery.com> (raw)
In-Reply-To: <5506184F.8090006@redhat.com>
Hi Martin,
I've applied your latest patch to top of trunk and looked at the code gen on powerpc-darwin9 (and a cross from x86-64-darwin12 => powerpc64-linux-gnu).
On 15 Mar 2015, at 23:39, Martin Sebor wrote:
> On 03/14/2015 08:34 AM, Segher Boessenkool wrote:
>> On Fri, Mar 13, 2015 at 03:54:57PM -0600, Martin Sebor wrote:
>>> Attached is a patch that eliminates the unused stack frame
>>> allocated by gcc 5 with -pg -mprofile-kernel on powepc64le
>>> and brings the code into parity with previous gcc versions.
>>>
>>> The patch doesn't do anything to change the emitted code
>>> when -mprofile-kernel is used without -pg. Since the former
>>> option isn't fully documented (as noted in pr 65372) it's
>>> unclear what effect it should be expected to have without
>>> -pg.
>>
>> -mprofile-kernel does nothing without profiling enabled. Maybe it
>> should just have been called -pk or something horrid like that.
>>
>> The effect it should have is to do what the only user of the option
>> (the 64-bit PowerPC Linux kernel) wants. The effect it does have
>> is to make the 64-bit ABI more like the 32-bit ABI for mcount.
>
> Thanks for the review and the clarification. FWIW, I mentioned
> -pg because the reporter had noted that in prior versions of
> GCC specifying -pg in addition to -mprofile-kernel wasn't
> necessary to get the expected effect.
>
>>
>>
>>> 2015-03-13 Anton Blanchard <anton@samba.org>
>>>
>>> PR target/63354
>>> * gcc/config/rs6000/linux64.h (ARGET_KEEP_LEAF_WHEN_PROFILED): Define.
>> ^ typo
This ^ will cause a bootstrap fail for every rs6000 target that doesn't include linux64.h.
(because rs6000_keep_leaf_when_profiled will be "defined but unused").
Since ISTM you intend this to apply to all rs6000 sub-targets, you might as well move it to rs6000.h?
>>
>>> * cc/config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled). New
>> ^ typo ^ typo
>>
>> It shouldn't have "gcc/" in the path names at all, actually.
>
> Sorry, I must have mangled the ChangeLog sopmehow while copying
> it from one terminal to another. I fixed it in the new patch
> (attached) along with the other issues you pointed out.
>
> I tested the changes in powerpc64*-linux-* native builds and on
> an x86_64 host in a build for the powerpc-unknown-linux-gnu and
> powerpc64-apple-darwin targets. Of these, the -mprofile-kernel
> option is only accepted for powerpc64*-linux-* (which was also
> confirmed by inspecting the sources) so I adjusted the test
> target accordingly and kept the body of
> rs6000_keep_leaf_when_profiled you suggested.
>
> Martin
>
>>
>>> +/* -mprofile-kernel code calls mcount before the function prolog,
>>
>> "prologue".
>>
>>> + so a profiled leaf function should stay a leaf function. */
>>> +
>>> +static bool
>>> +rs6000_keep_leaf_when_profiled (void)
>>> +{
>>> + return TARGET_PROFILE_KERNEL;
>>> +}
>>
>> Something like
>>
>> switch (DEFAULT_ABI)
>> {
>> case ABI_AIX:
>> case ABI_ELFv2:
>> return TARGET_PROFILE_KERNEL;
>>
>> default:
>> return true;
>> }
>>
>> although I'm not sure about Darwin here. More conservative is to
>> return false for anything untested, of course.
The change is 'no-op' on Darwin, since we pass a parameter to mcount a stack frame is always forced.
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.target/powerpc/pr63354.c
>>> @@ -0,0 +1,10 @@
>>> +/* { dg-do compile { target { powerpc*-*-* } } } */
>>> +/* { dg-options "-O2 -pg -mprofile-kernel" } */
>>> +
>>> +int foo (void)
>>> +{
>>> + return 1;
>>> +}
>>> +
>>> +/* { dg-final { scan-assembler "bl _mcount" } } */
>>> +/* { dg-final { scan-assembler-not "\(addi|stdu\) 1," } } */
>>
>> Either you should run this only on AIX/ELFv2 ABIs, or you want to
>> test for "stwu" as well. Bare "1" does not work for all assemblers
>> (only Darwin again?)
a bare register # will, indeed, fail for Darwin's native assembler (which expects r#).
cheers
Iain
>>
>>
>> Segher
>>
>
> <gcc-63354.patch>
next prev parent reply other threads:[~2015-03-21 19:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 21:55 Martin Sebor
2015-03-14 14:34 ` Segher Boessenkool
2015-03-15 23:40 ` Martin Sebor
2015-03-17 22:34 ` Segher Boessenkool
2015-03-21 19:48 ` Iain Sandoe [this message]
2015-03-24 2:50 ` Martin Sebor
2015-03-24 8:26 ` Iain Sandoe
2015-03-24 20:18 ` Martin Sebor
2015-03-24 11:51 ` Segher Boessenkool
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=210B149C-A8AB-4A0C-98AA-90D72741A7AF@codesourcery.com \
--to=iain@codesourcery.com \
--cc=anton@samba.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=msebor@redhat.com \
--cc=segher@kernel.crashing.org \
/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).