[all-commits] [llvm/llvm-project] 3b9059: Non constant size and offset in DWARF (#141106)

Tom Tromey via All-commits all-commits at lists.llvm.org
Wed Jun 25 11:20:58 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3b90597c2ceaae86608214f6b62b43e55823102b
      https://github.com/llvm/llvm-project/commit/3b90597c2ceaae86608214f6b62b43e55823102b
  Author: Tom Tromey <tromey at adacore.com>
  Date:   2025-06-25 (Wed, 25 Jun 2025)

  Changed paths:
    M clang/lib/CodeGen/CGDebugInfo.cpp
    M llvm/include/llvm/IR/DIBuilder.h
    M llvm/include/llvm/IR/DebugInfoMetadata.h
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/MetadataLoader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    M llvm/lib/IR/DIBuilder.cpp
    M llvm/lib/IR/DebugInfoMetadata.cpp
    M llvm/lib/IR/LLVMContextImpl.h
    M llvm/lib/IR/Verifier.cpp
    A llvm/test/DebugInfo/dynamic-bitfield.ll
    M llvm/unittests/IR/DebugInfoTest.cpp
    M llvm/unittests/IR/DebugTypeODRUniquingTest.cpp

  Log Message:
  -----------
  Non constant size and offset in DWARF (#141106)

In Ada, a record type can have a non-constant size, and a field can
appear at a non-constant bit offset in a record.

To support this, this patch changes DIType to record the size and offset
using metadata, rather than plain integers. In addition to a constant
offset, both DIVariable and DIExpression are now supported here.

One thing of note in this patch is the choice of how exactly to
represent a non-constant bit offset, with the difficulty being that
DWARF 5 does not support this. DWARF 3 did have a way to support a
non-constant byte offset, combined with a constant bit offset within the
byte, but this was deprecated in DWARF 4 and removed from DWARF 5.

This patch takes a simple approach: a DWARF extension allowing the use
of an expression with DW_AT_data_bit_offset. There is a corresponding
DWARF issue, see https://dwarfstd.org/issues/250501.1.html. The main
reason for this approach is that it keeps API simplicity: just a single
value is needed, rather than having separate data describing the byte
offset and the bit within the byte.



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