On Wed, Nov 6, 2024 at 3:35 PM Michal Jires <mji...@suse.cz> wrote: > > This if branch checks for comdat_type_p (GTY union tag) and then uses > incorrect union variant die_id.die_symbol. There is no way to create > this combination of valid values even if we ignore the GTY. > > Running testsuite with abort() in branch confirms that it is never taken.
Did you test with -fdebug-types-section? This code should be still needed to generate the linkonce debug-type sections. Note it doesn't work (very well) when combined with LTO. Richard. > gcc/ChangeLog: > > * dwarf2out.cc (output_comp_unit): Delete dead code. > --- > gcc/dwarf2out.cc | 25 +++++-------------------- > 1 file changed, 5 insertions(+), 20 deletions(-) > > diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc > index 38aedb64470..e10a5c78fe9 100644 > --- a/gcc/dwarf2out.cc > +++ b/gcc/dwarf2out.cc > @@ -11234,8 +11234,7 @@ static void > output_comp_unit (dw_die_ref die, int output_if_empty, > const unsigned char *dwo_id) > { > - const char *secname, *oldsym; > - char *tmp; > + const char *oldsym; > > /* Unless we are outputting main CU, we may throw away empty ones. */ > if (!output_if_empty && die->die_child == NULL) > @@ -11269,21 +11268,10 @@ output_comp_unit (dw_die_ref die, int > output_if_empty, > calc_die_sizes (die); > > oldsym = die->die_id.die_symbol; > - if (oldsym && die->comdat_type_p) > - { > - tmp = XALLOCAVEC (char, strlen (oldsym) + 24); > > - sprintf (tmp, ".gnu.linkonce.wi.%s", oldsym); > - secname = tmp; > - die->die_id.die_symbol = NULL; > - switch_to_section (get_section (secname, SECTION_DEBUG, NULL)); > - } > - else > - { > - switch_to_section (debug_info_section); > - ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label); > - info_section_emitted = true; > - } > + switch_to_section (debug_info_section); > + ASM_OUTPUT_LABEL (asm_out_file, debug_info_section_label); > + info_section_emitted = true; > > /* For LTO cross unit DIE refs we want a symbol on the start of the > debuginfo section, not on the CU DIE. */ > @@ -11322,10 +11310,7 @@ output_comp_unit (dw_die_ref die, int > output_if_empty, > /* Leave the marks on the main CU, so we can check them in > output_pubnames. */ > if (oldsym) > - { > - unmark_dies (die); > - die->die_id.die_symbol = oldsym; > - } > + unmark_dies (die); > } > > /* Whether to generate the DWARF accelerator tables in .debug_pubnames > -- > 2.47.0 >