This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] x86: Replace hard frame pointer with stack pointer - UNITS_PER_WORD
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: Segher Boessenkool <segher at kernel dot crashing dot org>, Jason Merrill <jason at redhat dot com>, Uros Bizjak <ubizjak at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, Cary Coutant <ccoutant at gmail dot com>
- Date: Mon, 3 Sep 2018 07:44:22 -0700
- Subject: Re: [PATCH] x86: Replace hard frame pointer with stack pointer - UNITS_PER_WORD
- References: <CAMe9rOoCNz6-oTZA3UnbGQLKHHu1C+o6PJBkL7Wqj4u7AoGwbQ@mail.gmail.com> <CADzB+2no2z+7Ua=wVg_tXjvOjDoCzawaw56kiM3BzYeLaGpFgg@mail.gmail.com> <CAMe9rOr_MKtJBSBNCwrZd_uYx=D9ypJk8s_0+RXEzvGwoXdxHQ@mail.gmail.com> <20180901113835.GG24439@gate.crashing.org> <20180902142758.GA7162@gmail.com> <alpine.LSU.2.21.1809031411260.7867@wotan.suse.de>
On Mon, Sep 3, 2018 at 7:32 AM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Sun, 2 Sep 2018, H.J. Lu wrote:
>
>> Here is the patch to replace hard frame pointer with stack pointer
>> - UNITS_PER_WORD in x86 backend.
>>
>> OK for trunk?
>>
>> +// { dg-options "-O -g -fno-omit-frame-pointer -fvar-tracking" }
>> +
>> +struct Foo
>> +{
>> + int bar(int a, int b, int c, int i1, int i2, int i3, int d);
>> +};
>> +
>> +int Foo::bar(int a, int b, int c, int i1, int i2, int i3, int d)
>> +{
>> + return 0;
>> +}
>> diff --git a/gcc/testsuite/g++.dg/pr86593-2.C b/gcc/testsuite/g++.dg/pr86593-2.C
>> +// { dg-options "-O -g -fno-omit-frame-pointer -fno-var-tracking" }
>> +
>> +struct Foo
>> +{
>> + int bar(int a, int b, int c, int i1, int i2, int i3, int d);
>> +};
>> +
>> +int Foo::bar(int a, int b, int c, int i1, int i2, int i3, int d)
>> +{
>> + return 0;
>> +}
>
> I can't seem to reproduce any ICEs with trunk on the above two testcases
> (configured for x86_64-linux):
>
> % ./gcc/cc1plus -quiet -O -g -fno-omit-frame-pointer -fno-var-tracking x.cc
> % ./gcc/cc1plus -quiet -O -g -fno-omit-frame-pointer -fvar-tracking x.cc
It is because of
gcc_assert ((SUPPORTS_STACK_ALIGNMENT
&& (elim == hard_frame_pointer_rtx <<<<<<<<<<<<
It allows hard frame pointer even if frame pointer isn't available.
|| elim == stack_pointer_rtx))
|| elim == (frame_pointer_needed
? hard_frame_pointer_rtx
: stack_pointer_rtx));
> I get the feeling this needs to be fixed somewhere else, namely
> eliminate_regs. Basically if the frame pointer isn't needed, then why is
> hard_frame_pointer_rtx even somewhere in the final RTL? The elimination
> you do explicitely in your new routines should have been done as part of
> general register elimination. Why isn't it?
hard frame pointer isn't referenced directly in the final RTL. It is arg
pointer in debug info, which is eliminated by hard frame pointer in
based_loc_desc.
--
H.J.