On Thu, 20 Jan 2022, Jakub Jelinek wrote: > Hi! > > riscv*-*-* are the only modern targets that !HAVE_AS_LEB128 (apparently > due to some aggressive linker optimizations). > As the following testcase shows, we mishandle in index_rnglists the > !HAVE_AS_LEB128 && !have_multiple_function_sections case. > > output_rnglists does roughly: > FOR_EACH_VEC_SAFE_ELT (ranges_table, i, r) > { > ... > if (block_num > 0) > { > ... > if (HAVE_AS_LEB128) > { > if (!have_multiple_function_sections) > { > // code not using r->*_entry > continue; > } > // code that sometimes doesn't use r->*_entry, > // sometimes r->begin_entry > } > else if (dwarf_split_debug_info) > { > // code that uses both r->begin_entry and r->end_entry > } > else > { > // code not using r->*_entry > } > } > else if (block_num < 0) > { > if (!have_multiple_function_sections) > gcc_unreachable (); > ... > } > } > and index_rnglists is what sets up those r->{begin,end}_entry members. > The code did an early if (!have_multiple_function_sections) continue; > which is fine for the HAVE_AS_LEB128 case, because r->*_entry is not > used in that case, but not for !HAVE_AS_LEB128 that uses it anyway. > > Fixed thusly, tested on the testcase with x86_64 -> riscv64 cross, > bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK. Thanks, Richard. > 2022-01-20 Jakub Jelinek <ja...@redhat.com> > > PR debug/103874 > * dwarf2out.cc (index_rnglists): For !HAVE_AS_LEB128 and > block_num > 0, index entry even if !have_multiple_function_sections. > > * gcc.dg/debug/dwarf2/pr103874.c: New test. > > --- gcc/dwarf2out.cc.jj 2022-01-18 11:58:59.000000000 +0100 > +++ gcc/dwarf2out.cc 2022-01-19 13:30:08.936008194 +0100 > @@ -12094,9 +12094,10 @@ index_rnglists (void) > if (r->label && r->idx != DW_RANGES_IDX_SKELETON) > r->idx = rnglist_idx++; > > - if (!have_multiple_function_sections) > - continue; > int block_num = r->num; > + if ((HAVE_AS_LEB128 || block_num < 0) > + && !have_multiple_function_sections) > + continue; > if (HAVE_AS_LEB128 && (r->label || r->maybe_new_sec)) > base = false; > if (block_num > 0) > --- gcc/testsuite/gcc.dg/debug/dwarf2/pr103874.c.jj 2022-01-19 > 13:35:25.485631843 +0100 > +++ gcc/testsuite/gcc.dg/debug/dwarf2/pr103874.c 2022-01-19 > 13:36:53.608413534 +0100 > @@ -0,0 +1,12 @@ > +/* PR debug/103874 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -g -gsplit-dwarf -dA > -Wno-implicit-function-declaration" } */ > + > +void > +foo (void) > +{ > + { > + bar (); > + baz (); > + } > +} > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)