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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
In a debugging session I also see

#1  0x0000000000e79f4c in check_die (
    die=<dw_die_ref 0x7ffff49f54b0 DW_TAG_subprogram <parent=0x7ffff49f5230
DW_TAG_subprogram>>) at ../../trunk/gcc/dwarf2out.c:6157
6157            gcc_assert (a->dw_attr != DW_AT_low_pc
(gdb) l
6152             instance tree [that has DW_AT_inline] should not contain any
6153             attributes which describe aspects of the subroutine which vary
6154             between distinct inlined expansions or distinct out-of-line
6155             expansions.  */
6156          FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
6157            gcc_assert (a->dw_attr != DW_AT_low_pc
6158                        && a->dw_attr != DW_AT_high_pc
6159                        && a->dw_attr != DW_AT_location
6160                        && a->dw_attr != DW_AT_frame_base
6161                        && a->dw_attr != DW_AT_call_all_calls
(gdb) p a->dw_attr
$1 = DW_AT_low_pc
(gdb) p debug_dwarf_die (die)
DIE    0: DW_TAG_subprogram (0x7ffff49f54b0)
  abbrev id: 0 offset: 0 mark: 0
  DW_AT_name: "exp_ch5__expand_assign_with_target_names__replace_target_name"
  DW_AT_artificial: 1
  DW_AT_inline: 2
  DW_AT_low_pc: label: *.LFB18
  DW_AT_high_pc: label: *.LFE18
  DW_AT_frame_base: location descriptor:
    (0x7ffff375d1e0) DW_OP_call_frame_cfa 0, 0

  DW_AT_static_link: location descriptor:
    (0x7ffff375d230) DW_OP_breg17 0, 0
    (0x7ffff375d280) DW_OP_plus_uconst 8, 0
    (0x7ffff375d2d0) DW_OP_deref 8, 0

  DW_AT_GNU_all_call_sites: 1
    DIE    0: DW_TAG_formal_parameter (0x7ffff49f56e0)
      abbrev id: 0 offset: 0 mark: 0
      DW_AT_name: "node"
      DW_AT_decl_file: "../../trunk/gcc/ada/atree.ads" (0)
      DW_AT_decl_line: 609
      DW_AT_type: die -> 0 (0x7ffff49d5960)
      DW_AT_location: location list -> label:*.LLST57
    DIE    0: DW_TAG_subprogram (0x7ffff49f5730)
      abbrev id: 0 offset: 0 mark: 0
      DW_AT_name:
"exp_ch5__expand_assign_with_target_names__replace_target_name__traverse"
      DW_AT_type: die -> 0 (0x7ffff4b60690)
      DW_AT_artificial: 1
        DIE    0: DW_TAG_formal_parameter (0x7ffff49f5820)
          abbrev id: 0 offset: 0 mark: 0
          DW_AT_name: "node"
          DW_AT_decl_file: "../../trunk/gcc/ada/atree.ads" (0)
          DW_AT_decl_line: 583
          DW_AT_type: die -> 0 (0x7ffff49d5960)
        DIE    0: DW_TAG_subprogram (0x7ffff49f5870)
          abbrev id: 0 offset: 0 mark: 0
          DW_AT_name:
"exp_ch5__expand_assign_with_target_names__replace_target_name__traverse__traverse_field"
          DW_AT_decl_file: "../../trunk/gcc/ada/atree.adb" (2)
          DW_AT_decl_line: 2470
          DW_AT_type: die -> 0 (0x7ffff4b60690)
            DIE    0: DW_TAG_formal_parameter (0x7ffff49f5af0)
              abbrev id: 0 offset: 0 mark: 0
              DW_AT_name: "nod"
              DW_AT_decl_file: "../../trunk/gcc/ada/atree.adb" (2)
              DW_AT_decl_line: 2458
              DW_AT_type: die -> 0 (0x7ffff49d5960)
            DIE    0: DW_TAG_formal_parameter (0x7ffff49f5b40)
              abbrev id: 0 offset: 0 mark: 0
              DW_AT_name: "fld"
              DW_AT_decl_file: "../../trunk/gcc/ada/atree.adb" (2)
              DW_AT_decl_line: 2459
              DW_AT_type: die -> 0 (0x7ffff49f5960)
            DIE    0: DW_TAG_formal_parameter (0x7ffff49f5b90)
              abbrev id: 0 offset: 0 mark: 0
              DW_AT_name: "fn"
              DW_AT_decl_file: "../../trunk/gcc/ada/atree.adb" (2)
              DW_AT_decl_line: 2460
              DW_AT_type: die -> 0 (0x7ffff49f5a00)
            DIE    0: DW_TAG_lexical_block (0x7ffff49f5be0)
...


and the high/low PC attributes are added when the DIE is already abstract
and inline via

#0  add_AT_low_high_pc (
    die=<dw_die_ref 0x7ffff49f54b0 DW_TAG_subprogram <parent=0x7ffff49f5230
DW_TAG_subprogram>>, lbl_low=0x3840f80 "*.LFB18", lbl_high=0x3c0fe60 "*.LFE18", 
    force_direct=false) at ../../trunk/gcc/dwarf2out.c:4210
#1  0x0000000000ea11f0 in gen_subprogram_die (decl=
    <function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>,
context_die=<dw_die_ref 0x0>)
    at ../../trunk/gcc/dwarf2out.c:22177
#2  0x0000000000eaa0d4 in gen_decl_die (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>, origin=<tree
0x0>, ctx=0x0, 
    context_die=<dw_die_ref 0x0>) at ../../trunk/gcc/dwarf2out.c:25187
#3  0x0000000000eab500 in dwarf2out_decl (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>) at
../../trunk/gcc/dwarf2out.c:25694
#4  0x0000000000eab54a in dwarf2out_function_decl (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>) at
../../trunk/gcc/dwarf2out.c:25709
#5  0x0000000000f37ee2 in rest_of_handle_final ()
    at ../../trunk/gcc/final.c:4506


which hints at that something goes wrong with setting the abtract / inline
flags.  They are added when the above DIE is generated as nested function
DIE while processing the outer function scopes:

#0  add_AT_flag (
    die=<dw_die_ref 0x7ffff49f54b0 DW_TAG_subprogram <parent=0x7ffff49f5230
DW_TAG_subprogram>>, attr_kind=DW_AT_artificial, flag=1)
    at ../../trunk/gcc/dwarf2out.c:4075
#1  0x0000000000ea08b8 in gen_subprogram_die (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>, 
    context_die=<dw_die_ref 0x7ffff49f5230 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:21969
#2  0x0000000000eaa0d4 in gen_decl_die (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>, origin=<tree
0x0>, ctx=0x0, 
    context_die=<dw_die_ref 0x7ffff49f5230 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:25187
#3  0x0000000000ea89ff in process_scope_var (stmt=<block 0x7ffff4ddc900>, 
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>, origin=<tree
0x0>, 
    context_die=<dw_die_ref 0x7ffff49f5230 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:24736
#4  0x0000000000ea8a78 in decls_for_scope (stmt=<block 0x7ffff4ddc900>, 
    context_die=<dw_die_ref 0x7ffff49f5230 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:24761
#5  0x0000000000ea1a00 in gen_subprogram_die (
    decl=<function_decl 0x7ffff6263100
exp_ch5__expand_assign_with_target_names>, context_die=<dw_die_ref
0x7ffff68c9000 DW_TAG_compile_unit>)
    at ../../trunk/gcc/dwarf2out.c:22370
#6  0x0000000000eaa0d4 in gen_decl_die (
    decl=<function_decl 0x7ffff6263100
exp_ch5__expand_assign_with_target_names>, origin=<tree 0x0>, ctx=0x0, 
    context_die=<dw_die_ref 0x7ffff68c9000 DW_TAG_compile_unit>)
    at ../../trunk/gcc/dwarf2out.c:25187
#7  0x0000000000eab500 in dwarf2out_decl (
    decl=<function_decl 0x7ffff6263100
exp_ch5__expand_assign_with_target_names>) at ../../trunk/gcc/dwarf2out.c:25694
#8  0x0000000000eaa849 in dwarf2out_early_global_decl (
    decl=<function_decl 0x7ffff4df7400
exp_ch5__expand_assign_with_target_names__replace_target>) at
../../trunk/gcc/dwarf2out.c:25348
#9  0x0000000000e14e9f in symbol_table::finalize_compilation_unit (
    this=0x7ffff68a6100) at ../../trunk/gcc/cgraphunit.c:2611

and the decl has DECL_ARTIFICIAL set and is auto-inline.

The DW_AT_inline is only set when we later process a function finally that
has this function inlined:

#0  add_AT_unsigned (
    die=<dw_die_ref 0x7ffff49f54b0 DW_TAG_subprogram <parent=0x7ffff49f5230
DW_TAG_subprogram>>, attr_kind=DW_AT_inline, unsigned_val=2)
    at ../../trunk/gcc/dwarf2out.c:4119
#1  0x0000000000ea0c07 in gen_subprogram_die (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>,
context_die=<dw_die_ref 0x0>)
    at ../../trunk/gcc/dwarf2out.c:22037
#2  0x0000000000eaa0d4 in gen_decl_die (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>, origin=<tree
0x0>, ctx=0x0, 
    context_die=<dw_die_ref 0x0>) at ../../trunk/gcc/dwarf2out.c:25187
#3  0x0000000000eab500 in dwarf2out_decl (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>) at
../../trunk/gcc/dwarf2out.c:25694
#4  0x0000000000e9fc6b in dwarf2out_abstract_function (
    decl=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>) at
../../trunk/gcc/dwarf2out.c:21587
#5  0x0000000000ea9ee2 in gen_decl_die (decl=<tree 0x0>, 
    origin=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>, ctx=0x0, 
    context_die=<dw_die_ref 0x7ffff36a1050 DW_TAG_lexical_block
<parent=0x7ffff369df50 DW_TAG_inlined_subroutine>>) at
../../trunk/gcc/dwarf2out.c:25144
#6  0x0000000000ea89ff in process_scope_var (stmt=<block 0x7ffff4ac8b40>, 
    decl=<tree 0x0>, 
    origin=<function_decl 0x7ffff4df7500
exp_ch5__expand_assign_with_target_names__replace_target_name>, 
    context_die=<dw_die_ref 0x7ffff36a1050 DW_TAG_lexical_block
<parent=0x7ffff369df50 DW_TAG_inlined_subroutine>>) at
../../trunk/gcc/dwarf2out.c:24736
#7  0x0000000000ea8b2a in decls_for_scope (stmt=<block 0x7ffff4ac8b40>, 
    context_die=<dw_die_ref 0x7ffff36a1050 DW_TAG_lexical_block
<parent=0x7ffff369df50 DW_TAG_inlined_subroutine>>) at
../../trunk/gcc/dwarf2out.c:24768
#8  0x0000000000ea3fe8 in gen_lexical_block_die (stmt=<block 0x7ffff4ac8b40>, 
    context_die=<dw_die_ref 0x7ffff369df50 DW_TAG_inlined_subroutine
<parent=0x7ffff49f3000 DW_TAG_subprogram>>) at
../../trunk/gcc/dwarf2out.c:23123
#9  0x0000000000ea870e in gen_block_die (stmt=<block 0x7ffff4ac8b40>, 
    context_die=<dw_die_ref 0x7ffff369df50 DW_TAG_inlined_subroutine
<parent=0x7ffff49f3000 DW_TAG_subprogram>>) at
../../trunk/gcc/dwarf2out.c:24698
#10 0x0000000000ea8ba7 in decls_for_scope (stmt=<block 0x7ffff4ac8ae0>, 
    context_die=<dw_die_ref 0x7ffff369df50 DW_TAG_inlined_subroutine
<parent=0x7ffff49f3000 DW_TAG_subprogram>>) at
../../trunk/gcc/dwarf2out.c:24779
#11 0x0000000000ea4187 in gen_inlined_subroutine_die (
    stmt=<block 0x7ffff4ac8ae0>, 
    context_die=<dw_die_ref 0x7ffff49f3000 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:23161
#12 0x0000000000ea86f9 in gen_block_die (stmt=<block 0x7ffff4ac8ae0>, 
    context_die=<dw_die_ref 0x7ffff49f3000 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:24695
#13 0x0000000000ea8ba7 in decls_for_scope (stmt=<block 0x7ffff4ddcf00>, 
    context_die=<dw_die_ref 0x7ffff49f3000 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:24779
#14 0x0000000000ea8723 in gen_block_die (stmt=<block 0x7ffff4ddcf00>, 
    context_die=<dw_die_ref 0x7ffff49f3000 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:24701
#15 0x0000000000ea8ba7 in decls_for_scope (stmt=<block 0x7ffff4ddce40>, 
    context_die=<dw_die_ref 0x7ffff49f3000 DW_TAG_subprogram
<parent=0x7ffff68c9000 DW_TAG_compile_unit>>) at
../../trunk/gcc/dwarf2out.c:24779
#16 0x0000000000ea1a00 in gen_subprogram_die (
    decl=<function_decl 0x7ffff625c500 exp_ch5__expand_n_assignment_statement>,
context_die=<dw_die_ref 0x7ffff68c9000 DW_TAG_compile_unit>)
    at ../../trunk/gcc/dwarf2out.c:22370
#17 0x0000000000eaa0d4 in gen_decl_die (
    decl=<function_decl 0x7ffff625c500 exp_ch5__expand_n_assignment_statement>,
origin=<tree 0x0>, ctx=0x0, 
    context_die=<dw_die_ref 0x7ffff68c9000 DW_TAG_compile_unit>)
    at ../../trunk/gcc/dwarf2out.c:25187
#18 0x0000000000eab500 in dwarf2out_decl (
    decl=<function_decl 0x7ffff625c500 exp_ch5__expand_n_assignment_statement>)
    at ../../trunk/gcc/dwarf2out.c:25694
#19 0x0000000000eab54a in dwarf2out_function_decl (
    decl=<function_decl 0x7ffff625c500 exp_ch5__expand_n_assignment_statement>)
    at ../../trunk/gcc/dwarf2out.c:25709
#20 0x0000000000f37ee2 in rest_of_handle_final ()
    at ../../trunk/gcc/final.c:4506

that's obviously too late, but it seems that dwarf2out_abstract_function
doesn't do its work (it fails to generate a new abstract instance here
but that should have happened during inlining itself anyway...).  So
somehow the twisted maze of conditions when and when not to generate a new
DIE or re-use the existing DIE in get_subprogram_die fails... (the out-of-line
copy of the inline is not yet finalized here).

Reply via email to