https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83157

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
First of all the clone should have pointed to the abstract origin of
guality_main
but it seems we re-use that for the concrete instance failing to see it
was "inlined".  So the bogus location shoudln't be visible in the
guality_main.constprop () context.

After we fixed that we can continue investigating (if it still fails).

So:

;; guality_main.constprop()
 <1><9f0>: Abbrev Number: 42 (DW_TAG_subprogram)
    <9f1>   DW_AT_abstract_origin: <0x474>

and

;; guality_main()
 <1><994>: Abbrev Number: 42 (DW_TAG_subprogram)
    <995>   DW_AT_abstract_origin: <0x474>

refer to the same abstract instance of guality_main.  But

 <2><a0b>: Abbrev Number: 46 (DW_TAG_variable)
    <a0c>   DW_AT_abstract_origin: <0x9c1>

doesn't refer to the abstract origin copy of the variable but the concrete
instace one.

As said, with current trunk I don't even see a DIE for guality_main.constprop
because it is inlined (but the guality test still fails).  Your reduced
testcase reproduces the issue for me.

Ah...  I guess this all might happen because the actual DECL refers to both
the abstract instance and the concrete instance and
add_abstract_origin_attribute simply never expects the concrete instance
to exist already...  But creating the DIE for the clone happens late enough
here 
(when it is finally output):

Breakpoint 6, equate_decl_number_to_die (
    decl=<var_decl 0x7ffff6a11f30 boring>, 
    decl_die=<dw_die_ref 0x7ffff6705d20 DW_TAG_variable <parent=0x7ffff6705c30
DW_TAG_subprogram>>) at /space/rguenther/src/svn/trunk2/gcc/dwarf2out.c:5763
5763      unsigned int decl_id = DECL_UID (decl);
...
Breakpoint 6, equate_decl_number_to_die (
    decl=<var_decl 0x7ffff6a11f30 boring>, 
    decl_die=<dw_die_ref 0x7ffff675de60 DW_TAG_variable <parent=0x7ffff675daa0
DW_TAG_subprogram>>) at /space/rguenther/src/svn/trunk2/gcc/dwarf2out.c:5763
5763      unsigned int decl_id = DECL_UID (decl);
...
Breakpoint 5, add_abstract_origin_attribute (
    die=<dw_die_ref 0x7ffff6763460 DW_TAG_variable <parent=0x7ffff67633c0
DW_TAG_subprogram>>, origin=<var_decl 0x7ffff6a11f30 boring>)
    at /space/rguenther/src/svn/trunk2/gcc/dwarf2out.c:20445
20445     dw_die_ref origin_die = NULL;
boring
(gdb) p debug_generic_expr (cfun->decl)
guality_main.constprop
(gdb) p origin_die
$24 = <dw_die_ref 0x7ffff675de60 DW_TAG_variable <parent=0x7ffff675daa0
DW_TAG_subprogram>>


This means we're lacking an "early" DIE creation stage for the function clone.
IPA materialization happens early enough for this.

Forgoing the 1:1 mapping of decl to DIE would be another possibility to fix
this (making the global map always point to the abstract copy and adding
a local map for querying during dwarf2out_function_decl).

Jason?

Reply via email to