This is the mail archive of the
mailing list for the GCC project.
Re: DWARF: Represent hard frame pointer as stack pointer + offset
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: 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: Fri, 31 Aug 2018 14:54:17 -0700
- Subject: Re: DWARF: Represent hard frame pointer as stack pointer + offset
- References: <CAMe9rOoCNz6-oTZA3UnbGQLKHHu1C+o6PJBkL7Wqj4u7AoGwbQ@mail.gmail.com> <CADzB+2no2z+7Ua=wVg_tXjvOjDoCzawaw56kiM3BzYeLaGpFgg@mail.gmail.com>
On Fri, Aug 31, 2018 at 1:32 PM, Jason Merrill <firstname.lastname@example.org> wrote:
> On Fri, Aug 31, 2018 at 3:33 PM, H.J. Lu <email@example.com> wrote:
>> On Thu, Aug 30, 2018 at 10:21 AM, Jason Merrill <firstname.lastname@example.org> wrote:
>>>> r138335 allowed arg_pointer_rtx to be eliminated by either FP or SP,
>>>> but only when dynamic stack alignment is supported. In this case,
>>>> arg_pointer_rtx is eliminated by FP even when frame_pointer_needed
>>>> is false and there is no dynamic stack alignment at all.
>>>>> gcc_assert (elim == stack_pointer_rtx || (frame_pointer_needed && elim
>>>>> == hard_frame_pointer_rtx));
>>>>> so as not to allow eliminating to an uninitialized FP.
>>>> FP isn't uninitialized. It is initialized the same way as in the case of
>>>> SUPPORTS_STACK_ALIGNMENT is true.
>>> How is that? Why would it be initialized when frame_pointer_needed is
>>> false? What does it mean for frame_pointer_needed to be false, if
>>> not, as in the documentation of -fomit-frame-pointer,
>>> "This avoids the instructions to save, set up and restore the frame
>>> pointer; on many targets it also makes an extra register available."
>> A backend may not set up frame pointer even with -fno-omit-frame-pointer.
>> In the case of x86, hard frame pointer can be represented by stack pointer
>> - UNITS_PER_WORD.
>> This patch adds hard_frame_pointer_from_stack_pointer_plus_offset and
>> hard_frame_pointer_offset to rtl_data to allow a backend to represent
>> hard frame pointer as stack pointer + offset.
> Shouldn't this be fixed in eliminate_regs rather than dwarf2out?
With -fno-omit-frame-pointer, arg pointer is eliminated with hard frame
Author: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu Aug 10 15:29:05 2017 +0000
i386: Don't use frame pointer without stack access
When there is no stack access, there is no need to use frame pointer
even if -fno-omit-frame-pointer is used and caller's frame pointer is
changed it in the last minute. It is too late to go back. When it is done,
hard frame pointer must be replaced by stack pointer - UNITS_PER_WORD
if it is ever used.