[all-commits] [llvm/llvm-project] becbbb: Round up zero-sized symbols to 1 byte in `.debug_a...

Patrick Walton via All-commits all-commits at lists.llvm.org
Mon Jun 27 10:13:57 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: becbbb7e3c8141b3346211faf9359f629cbf4e4d
      https://github.com/llvm/llvm-project/commit/becbbb7e3c8141b3346211faf9359f629cbf4e4d
  Author: Patrick Walton <pcwalton at fb.com>
  Date:   2022-06-27 (Mon, 27 Jun 2022)

  Changed paths:
    M llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    A llvm/test/CodeGen/X86/dwarf-aranges-available-externally.ll
    A llvm/test/CodeGen/X86/dwarf-aranges-zero-size.ll

  Log Message:
  -----------
  Round up zero-sized symbols to 1 byte in `.debug_aranges` (without breaking other logic).

This commit modifies the AsmPrinter to avoid emitting any zero-sized symbols to
the .debug_aranges table, by rounding their size up to 1. Entries with zero
length violate the DWARF 5 spec, which states:

> Each descriptor is a triple consisting of a segment selector, the beginning
> address within that segment of a range of text or data covered by some entry
> owned by the corresponding compilation unit, followed by the non-zero length
> of that range.

In practice, these zero-sized entries produce annoying warnings in lld and
cause GNU binutils to truncate the table when parsing it.

Other parts of LLVM, such as DWARFDebugARanges in the DebugInfo module
(specifically the appendRange method), already avoid emitting zero-sized
symbols to .debug_aranges, but not comprehensively in the AsmPrinter. In fact,
the AsmPrinter does try to avoid emitting such zero-sized symbols when labels
aren't involved, but doesn't when the symbol to emitted is a difference of two
labels; this patch extends that logic to handle the case in which the symbol is
defined via labels.

Furthermore, this patch fixes a bug in which `available_externally` symbols
would cause unpredictable values to be emitted into the `.debug_aranges` table
under certain circumstances. In practice I don't believe that this caused
issues up until now, but the root cause of this bug--an invalid DenseMap
lookup--triggered failures in Chromium when combined with an earlier version of
this patch. Therefore, this patch fixes that bug too.

This is a revised version of diff D126257, which was reverted due to breaking
tests. The now-reverted version of this patch didn't distinguish between
symbols that didn't have their size reported to the DwarfDebug handler and
those that had their size reported to be zero. This new version of the patch
instead restricts the special handling only to the symbols whose size is
definitively known to be zero.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D126835




More information about the All-commits mailing list