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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|8.0                         |6.5
            Summary|[8 regression]              |[6/7/8 regression]
                   |gcc.dg/guality/pr41616-1.c  |gcc.dg/guality/pr41616-1.c
                   |fail                        |fail, inline instances
                   |                            |refer to concrete instance
                   |                            |as abstract origin

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
In the end this is probably also an issue with how we represent clones (and how
we do not, and cannot, generate an "early" DIE for it).

It might be better to view a clone of F as a wrapper around an inline instance
of F which means we wouldn't add any elaborate debug for the clone itself but
its
subroutine DIE would stand on its own (no abstract origin) and the relation to
F would be fully via the inlined-subroutine DIE.

Thus avoid the abstract origin stuff tree_function_versioning does:

  /* Output the inlining info for this abstract function, since it has been
     inlined.  If we don't do this now, we can lose the information about the
     variables in the function when the blocks get blown away as soon as we
     remove the cgraph node.  */
  (*debug_hooks->outlining_inline_function) (old_decl);

  DECL_ARTIFICIAL (new_decl) = 1;
  DECL_ABSTRACT_ORIGIN (new_decl) = DECL_ORIGIN (old_decl);
  if (DECL_ORIGIN (old_decl) == old_decl)
    old_version_node->used_as_abstract_origin = true;
  DECL_FUNCTION_PERSONALITY (new_decl) = DECL_FUNCTION_PERSONALITY (old_decl);

it might be even possible to implicitely hack things up by adding a
inlined_function_outer_scope_p () scope containing the abstract origin instead.

A quick hack shows it doesn't really resolve the issue here and I'm not sure
the same issue doesn't exist with regular inlines if a concrete instance
prevails as well.  Indeed.  The following small C testcase shows the exact
same issue at -O2 -g:

int foo (int i)
{
  volatile int boring = 1;
  return boring + i;
}

int bar()
{
  int tem = 1;
  return tem + foo (0);
}

 <1><2d>: Abbrev Number: 2 (DW_TAG_subprogram)
    <2e>   DW_AT_external    : 1
    <2e>   DW_AT_name        : bar
...
 <2><5c>: Abbrev Number: 4 (DW_TAG_inlined_subroutine)
    <5d>   DW_AT_abstract_origin: <0xa2>
    <61>   DW_AT_low_pc      : 0x10
    <69>   DW_AT_high_pc     : 0xc
    <71>   DW_AT_call_file   : 1
    <72>   DW_AT_call_line   : 10
    <73>   DW_AT_call_column : 16
 <3><74>: Abbrev Number: 5 (DW_TAG_formal_parameter)
    <75>   DW_AT_abstract_origin: <0xb3>
    <79>   DW_AT_location    : 0x0 (location list)
 <3><7d>: Abbrev Number: 6 (DW_TAG_lexical_block)
    <7e>   DW_AT_low_pc      : 0x10
    <86>   DW_AT_high_pc     : 0xc
 <4><8e>: Abbrev Number: 7 (DW_TAG_variable)
    <8f>   DW_AT_abstract_origin: <0xe8>     // refers to concrete instance!
...
 <1><a2>: Abbrev Number: 10 (DW_TAG_subprogram)    // abstract instance
    <a3>   DW_AT_external    : 1
    <a3>   DW_AT_name        : foo
...
 <2><b3>: Abbrev Number: 11 (DW_TAG_formal_parameter)
    <b4>   DW_AT_name        : i
    <b6>   DW_AT_decl_file   : 1
    <b7>   DW_AT_decl_line   : 1
    <b8>   DW_AT_decl_column : 14
    <b9>   DW_AT_type        : <0x96>
 <2><bd>: Abbrev Number: 12 (DW_TAG_variable)
    <be>   DW_AT_name        : (indirect string, offset: 0x8e): boring
    <c2>   DW_AT_decl_file   : 1
    <c3>   DW_AT_decl_line   : 3
    <c4>   DW_AT_decl_column : 16
    <c5>   DW_AT_type        : <0x9d>
 <2><c9>: Abbrev Number: 0
 <1><ca>: Abbrev Number: 13 (DW_TAG_subprogram)  // concrete instance
    <cb>   DW_AT_abstract_origin: <0xa2>
    <cf>   DW_AT_low_pc      : 0x0
    <d7>   DW_AT_high_pc     : 0xf
    <df>   DW_AT_frame_base  : 1 byte block: 9c         (DW_OP_call_frame_cfa)
    <e1>   DW_AT_GNU_all_call_sites: 1
 <2><e1>: Abbrev Number: 14 (DW_TAG_formal_parameter)
    <e2>   DW_AT_abstract_origin: <0xb3>
    <e6>   DW_AT_location    : 1 byte block: 55         (DW_OP_reg5 (rdi))
 <2><e8>: Abbrev Number: 15 (DW_TAG_variable)
    <e9>   DW_AT_abstract_origin: <0xbd>
    <ed>   DW_AT_location    : 2 byte block: 91 74      (DW_OP_fbreg: -12)
 <2><f0>: Abbrev Number: 0


The same behavior already exists with GCC 7 and GCC 6 but not GCC 5.

Reply via email to