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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:3991e4c752b3450decdb36e0b562e044ce653b3d

commit r11-9505-g3991e4c752b3450decdb36e0b562e044ce653b3d
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu Jan 20 11:58:20 2022 +0100

    dwarf2out: Fix -gsplit-dwarf on riscv [PR103874]

    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.

    2022-01-20  Jakub Jelinek  <ja...@redhat.com>

            PR debug/103874
            * dwarf2out.c (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.

    (cherry picked from commit 68f03ac49cb4f585dbce78dc9e4c4a9ec950e83c)

Reply via email to