public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Michael Matz <matz@suse.de>,
	Segher Boessenkool <segher@kernel.crashing.org>,
		GCC Patches <gcc-patches@gcc.gnu.org>,
	Cary Coutant <ccoutant@gmail.com>
Subject: Re: [PATCH] DWARF: Allow hard frame pointer even if frame pointer isn't used
Date: Tue, 04 Sep 2018 20:03:00 -0000	[thread overview]
Message-ID: <CADzB+2=M7vM7J6V99YLngun4YjTE_1SfNUPT0MX4yrcJkBe3Dg@mail.gmail.com> (raw)
In-Reply-To: <CAMe9rOpuzruGwKLemne71evtdVuKTAK9Z6MpUZng-eGGGQU5ww@mail.gmail.com>

OK.

On Tue, Sep 4, 2018 at 11:13 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Sep 3, 2018 at 10:01 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Sep 3, 2018 at 9:44 AM, Michael Matz <matz@suse.de> wrote:
>>> Hi,
>>>
>>> On Mon, 3 Sep 2018, H.J. Lu wrote:
>>>
>>>> > 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.
>>>
>>> Yeah, that's what I thought as well, but it's correct:
>>>
>>> % ./gcc/cc1plus -quiet -O2 -g -fno-omit-frame-pointer -fvar-tracking x.cc
>>> % gcc -c x.s
>>> % readelf -wfi x.o
>>> ...
>>>  <1><8a>: Abbrev Number: 9 (DW_TAG_subprogram)
>>>     <8b>   DW_AT_specification: <0x3a>
>>>     <8f>   DW_AT_decl_line   : 6
>>>     <90>   DW_AT_decl_column : 5
>>>     <91>   DW_AT_object_pointer: <0xa7>
>>>     <95>   DW_AT_low_pc      : 0x0
>>>     <9d>   DW_AT_high_pc     : 0x3
>>>     <a5>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
>>>     <a7>   DW_AT_GNU_all_call_sites: 1
>>> ...
>>>  <2><fe>: Abbrev Number: 11 (DW_TAG_formal_parameter)
>>>     <ff>   DW_AT_name        : d
>>>     <101>   DW_AT_decl_file   : 1
>>>     <102>   DW_AT_decl_line   : 6
>>>     <103>   DW_AT_decl_column : 63
>>>     <104>   DW_AT_type        : <0x78>
>>>     <108>   DW_AT_location    : 2 byte block: 91 8      (DW_OP_fbreg: 8)
>>> ...
>>>   DW_CFA_def_cfa: r7 (rsp) ofs 8
>>>   DW_CFA_offset: r16 (rip) at cfa-8
>>>   DW_CFA_nop
>>>   DW_CFA_nop
>>> ...
>>>
>>> So, argument 'd' is supposed to be at DW_AT_frame_base + 8, which is
>>> %rsp+8+8, aka %rsp+16, which is correct given that it's the eigth argument
>>> (including the implicit this parameter).
>>
>> Can we use DW_AT_frame_base when the frame pointer isn't available?
>> If yes,
>>
>>          gcc_assert ((SUPPORTS_STACK_ALIGNMENT
>>                        && (elim == hard_frame_pointer_rtx
>>                            || elim == stack_pointer_rtx))
>>                       || elim == (frame_pointer_needed
>>                                   ? hard_frame_pointer_rtx
>>                                   : stack_pointer_rtx));
>>
>> should be changed to
>>
>>           gcc_assert (elim == hard_frame_pointer_rtx
>>                       || elim == stack_pointer_rtx);
>>
>> This will also fix:
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86593
>>
>
> Since hard frame pointer is encoded with DW_OP_fbreg which uses the
> DW_AT_frame_base attribute, not hard frame pointer directly, we should
> allow hard frame pointer when generating DWARF info even if frame pointer
> isn't used.
>
> OK for trunk?
>
> --
> H.J.

      reply	other threads:[~2018-09-04 20:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 15:13 H.J. Lu
2018-09-04 20:03 ` Jason Merrill [this message]

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='CADzB+2=M7vM7J6V99YLngun4YjTE_1SfNUPT0MX4yrcJkBe3Dg@mail.gmail.com' \
    --to=jason@redhat.com \
    --cc=ccoutant@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=matz@suse.de \
    --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).