This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix profiledbootstrap ada checking failure (PR debug/79255)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 24 Mar 2017 13:53:52 +0100
- Subject: Re: [PATCH] Fix profiledbootstrap ada checking failure (PR debug/79255)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A687F8F253
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A687F8F253
- References: <20170323204414.GZ11094@tucnak> <CADzB+2mj8WxSAUvPWcywYt=hEn=0VbAYMSoVH6rxypPV-0kC6A@mail.gmail.com> <20170324074639.GG11094@tucnak> <CAFiYyc1XHY_z3UkUrhZA8oDu0Jz71jKGCdu2puXbn3g5RByWCA@mail.gmail.com> <20170324084326.GH11094@tucnak> <CAFiYyc3M+dA+2jY4oUKdvk_8dcR9D9BA7v-HmuPi4Voh33N-kw@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Mar 24, 2017 at 12:45:28PM +0100, Richard Biener wrote:
> On Fri, Mar 24, 2017 at 9:43 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > On Fri, Mar 24, 2017 at 09:29:00AM +0100, Richard Biener wrote:
> >> Yeah, the thing BLOCK_NONLOCALIZED_VARS wants to do is optimize generated
> >> dwarf by adding a DW_AT_abstract_origin (just to refer to the
> >> subprogram DIE) but
> >
> > Well, for FUNCTION_DECLs in BLOCK_VARS/BLOCK_NONLOCALIZED_VARS we actually don't
> > emit any further DIE and so there is no DW_AT_abstract_origin.
> > E.g. gen_subprogram_die has:
> > /* Detect and ignore this case, where we are trying to output
> > something we have already output. */
> > if (get_AT (old_die, DW_AT_low_pc)
> > || get_AT (old_die, DW_AT_ranges))
> > return;
>
> Hmm, but we do want to put the function in scope? THus
>
> void foo () {}
> void bar ()
> {
> int foo;
> {
> void foo();
> foo();
> }
> }
>
> should have a DIE for foo in bar (possibly refering to the concrete instance
> for optimization).
We actually do that. If I change your testcase so that it actually triggers
the changed part of the code (so there is inlining etc.), so:
volatile int v;
__attribute__((noinline)) void foo () { v++; }
static inline void bar ()
{
int foo;
{
void foo();
foo();
}
}
void
baz (void)
{
bar ();
bar ();
}
then at -gdwarf-3 -dA -O2 the difference between vanilla GCC and my patched GCC is
following (used -gdwarf-3 so that there are no DW_FORM_flag_present that
result in DIE offset changes):
.uleb128 0xd # (DIE (0x117) DW_TAG_subprogram)
.ascii "bar\0" # DW_AT_name
.byte 0x1 # DW_AT_decl_file (prQQ.c)
.byte 0x3 # DW_AT_decl_line
.byte 0x3 # DW_AT_inline
.long 0x13c # DW_AT_sibling
.uleb128 0xe # (DIE (0x123) DW_TAG_variable)
.ascii "foo\0" # DW_AT_name
.byte 0x1 # DW_AT_decl_file (prQQ.c)
.byte 0x5 # DW_AT_decl_line
.long 0x41 # DW_AT_type
.uleb128 0xf # (DIE (0x12e) DW_TAG_lexical_block)
.uleb128 0x10 # (DIE (0x12f) DW_TAG_subprogram)
.byte 0x1 # DW_AT_external
.ascii "foo\0" # DW_AT_name
.byte 0x1 # DW_AT_decl_file (prQQ.c)
.byte 0x7 # DW_AT_decl_line
- .byte 0 # DW_AT_inline
+ .byte 0x1 # DW_AT_declaration
.uleb128 0x11 # (DIE (0x138) DW_TAG_unspecified_parameters)
.byte 0 # end of children of DIE 0x12f
.byte 0 # end of children of DIE 0x12e
.byte 0 # end of children of DIE 0x117
.uleb128 0x12 # (DIE (0x13c) DW_TAG_subprogram)
.byte 0x1 # DW_AT_external
.ascii "foo\0" # DW_AT_name
.byte 0x1 # DW_AT_decl_file (prQQ.c)
.byte 0x2 # DW_AT_decl_line
.quad .LFB0 # DW_AT_low_pc
.quad .LFE0 # DW_AT_high_pc
.byte 0x1 # DW_AT_frame_base
.byte 0x9c # DW_OP_call_frame_cfa
.byte 0x1 # DW_AT_GNU_all_call_sites
.byte 0 # end of children of DIE 0xb
and corresponding change in .debug_abbrev.
That seems to be the right change to me, inside of bar (the DW_AT_inline
one) we have a declaration of foo, and we properly use DW_AT_declaration for
it, then at the toplevel we actually have the full definition die for foo,
and then we have in two spots inside baz
.uleb128 0x6 # (DIE (0x6d) DW_TAG_inlined_subroutine)
.long 0x117 # DW_AT_abstract_origin
without the need to duplicate the foo declaration in there,
that is inherited through DW_AT_abstract_origin.
Jakub