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

Patrick Walton via All-commits all-commits at lists.llvm.org
Wed May 25 13:32:05 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 256a52d9aac8a9e98fbfd6a3d91090bf127cef7d
      https://github.com/llvm/llvm-project/commit/256a52d9aac8a9e98fbfd6a3d91090bf127cef7d
  Author: Patrick Walton <pcwalton at fb.com>
  Date:   2022-05-25 (Wed, 25 May 2022)

  Changed paths:
    M llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    A llvm/test/CodeGen/Generic/dwarf-aranges-zero-size.ll
    M llvm/test/DebugInfo/MSP430/dwarf-basics-v5.ll
    M llvm/test/DebugInfo/X86/dwarf-aranges.ll

  Log Message:
  -----------
  Round up zero-sized symbols to 1 byte in `.debug_aranges`.

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.

Reviewed By: dblaikie

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




More information about the All-commits mailing list