[all-commits] [llvm/llvm-project] b0bf48: Two DWARF variant part improvements (#138953)

Tom Tromey via All-commits all-commits at lists.llvm.org
Thu May 8 09:41:36 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b0bf48d44e5502092c55ea7f353f8c4100635601
      https://github.com/llvm/llvm-project/commit/b0bf48d44e5502092c55ea7f353f8c4100635601
  Author: Tom Tromey <tromey at adacore.com>
  Date:   2025-05-08 (Thu, 08 May 2025)

  Changed paths:
    M llvm/include/llvm/IR/DIBuilder.h
    M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
    A llvm/test/DebugInfo/Generic/discriminant-member.ll

  Log Message:
  -----------
  Two DWARF variant part improvements (#138953)

This patch adds a couple of improvements to the LLVM emission of DWARF
variant parts. One of these is desirable for Ada, and the other is
required.

Currently, when emitting a discriminant, LLVM follows the precise letter
of the DWARF standard, which says:

    If the variant part has a discriminant, the discriminant is
    represented by a separate debugging information entry which is a
    child of the variant part entry.

However, for Ada this does not really make sense. In Ada, the
discriminant field exists outside of any variant part, and it makes more
sense to emit it separately rather than redundantly emit the field once
for each variant part.

This extension was arrived at when this was implemented in GCC, and was
accepted for DWARF 6, see:

    https://dwarfstd.org/issues/180123.1.html

Here the patch simply lifts this restriction: if the discriminant field
was already emitted, it isn't re-emitted. This approach allows the Ada
compiler to do what it needs without affecting the Rust output.

Second, this patch extends the discriminant to allow multiple values.
This is needed by Ada. Here, I chose to use a ConstantDataArray of pairs
of integers, with each pair representing a range, as Ada also allows
ranges here. This seemed like a reasonably convenient representation.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list