https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83941
Bug ID: 83941 Summary: Debug info generated with -flto contains useless forwarders Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: lto, missed-optimization Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- Currently for int main() { int i; return 0; } we emit <1><174>: Abbrev Number: 2 (DW_TAG_subprogram) <175> DW_AT_external : 1 <175> DW_AT_name : (indirect string, offset: 0x152): main <179> DW_AT_decl_file : 1 <17a> DW_AT_decl_line : 1 <17b> DW_AT_decl_column : 5 <17c> DW_AT_type : <0x18f> <180> DW_AT_sibling : <0x18f> <2><184>: Abbrev Number: 3 (DW_TAG_variable) <185> DW_AT_name : i <187> DW_AT_decl_file : 1 <188> DW_AT_decl_line : 3 <189> DW_AT_decl_column : 7 <18a> DW_AT_type : <0x18f> <2><18e>: Abbrev Number: 0 <1><18f>: Abbrev Number: 4 (DW_TAG_base_type) <190> DW_AT_byte_size : 4 <191> DW_AT_encoding : 5 (signed) <192> DW_AT_name : int in the early unit and <1><1c9>: Abbrev Number: 3 (DW_TAG_subprogram) <1ca> DW_AT_abstract_origin: <0x174> <1ce> DW_AT_low_pc : 0x4004b6 <1d6> DW_AT_high_pc : 0x6 <1de> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa) <1e0> DW_AT_GNU_all_call_sites: 1 <2><1e0>: Abbrev Number: 4 (DW_TAG_variable) <1e1> DW_AT_abstract_origin: <0x184> in the late one. Note the "useless" DIE for 'i' which isn't necessary to make gdb print '<optimized out>' - gdb happily picks up variables for name lookup without the extra forwarder via the DW_TAG_subprogram abstract origin children.