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
On Mon, Sep 3, 2018 at 8:20 AM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Mon, 3 Sep 2018, H.J. Lu wrote:
>
>> > % ./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 <<<<<<<<<<<<
>
> So, what's the testcase testing then? Before the patch it doesn't ICE,
> after the patch it doesn't ICE. What should I look out for so I can see
> that what the testcase is producing without the patch is wrong?
Before the patch, debug info is wrong since it uses hard frame pointer
which isn't set up for the function. You can do "readelf -w" on .o file to
verify the debug info.
>> > 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.
>
> You talking about this, right:
>
> /* We only use "frame base" when we're sure we're talking about the
> post-prologue local stack frame. We do this by *not* running
> register elimination until this point, and recognizing the special
> argument pointer and soft frame pointer rtx's. */
> if (reg == arg_pointer_rtx || reg == frame_pointer_rtx)
> {
> rtx elim = (ira_use_lra_p
> ? lra_eliminate_regs (reg, VOIDmode, NULL_RTX)
> : eliminate_regs (reg, VOIDmode, NULL_RTX));
>
> if (elim != reg)
> {
> ...
>
> So, why would eliminate_regs return hard_frame_pointer_rtx if no frame
> pointer is desired?
>
Frame pointer was skipped at the last minute in x86_finalize_stack_frame_flags.
But eliminate_regs uses the info which was computed when frame pointer was
available.
--
H.J.