[all-commits] [llvm/llvm-project] abdbaf: [DWARFLinker] Adjust DW_AT_LLVM_stmt_sequence for ...

alx32 via All-commits all-commits at lists.llvm.org
Thu Mar 13 02:55:13 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: abdbaff5441e35a6e26f770145b62d73f4a55f48
      https://github.com/llvm/llvm-project/commit/abdbaff5441e35a6e26f770145b62d73f4a55f48
  Author: alx32 <103613512+alx32 at users.noreply.github.com>
  Date:   2025-03-13 (Thu, 13 Mar 2025)

  Changed paths:
    M llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
    M llvm/include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h
    M llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h
    M llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
    M llvm/lib/DWARFLinker/Classic/DWARFLinkerCompileUnit.cpp
    M llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
    A llvm/test/tools/dsymutil/ARM/stmt-seq-macho.test
    A llvm/test/tools/dsymutil/Inputs/private/tmp/stmt_seq/stmt_seq_macho.exe
    A llvm/test/tools/dsymutil/Inputs/private/tmp/stmt_seq/stmt_seq_macho.o

  Log Message:
  -----------
  [DWARFLinker] Adjust DW_AT_LLVM_stmt_sequence for rewritten line tables (#128953)

**Summary:**  
This update adds handling for `DW_AT_LLVM_stmt_sequence` attributes in
the DWARF linker. These attributes point to rows in the line table,
which gets rewritten during linking. Since the row positions change, the
offsets in these attributes need to be updated to match the new layout
in the output `.debug_line` section. The changes add new data structures
and tweak existing functions to track and fix these attributes.

**Background**
In https://github.com/llvm/llvm-project/pull/110192 we added support to
clang to generate the `DW_AT_LLVM_stmt_sequence` attribute for
`DW_TAG_subprogram`'s. Corresponding RFC: [New DWARF Attribute for
Symbolication of Merged
Functions](https://discourse.llvm.org/t/rfc-new-dwarf-attribute-for-symbolication-of-merged-functions/79434).
This attribute holds a label pointing to the offset in the line table
where the function's line entries begin.

**Implementation details:**  
Here’s what’s changed in the code:  
- **New Tracking in `CompileUnit`:** A `StmtSeqListAttributes` vector is
added to the `CompileUnit` class. It stores the locations where
`DW_AT_LLVM_stmt_sequence` attributes need to be patched, recorded when
cloning DIEs (debug info entries).
- **Updated `emitLineTableForUnit` Function:** This function now has an
optional `RowOffsets` parameter. It collects the byte offsets of each
row in the output line table. We only need to use this functionality if
`DW_AT_LLVM_stmt_sequence` attributes are present in the unit.
- **Row Tracking with `TrackedRow`:** A `TrackedRow` struct keeps track
of each input row’s original index and whether it starts a sequence in
the output table. This links old rows to their new positions in the
rewritten line table. Several implementations were considered and
prototyped here, but so far this has proven the simplest and cleanest
approach.
- **Patching Step:** After the line table is written, the linker uses
the data in `TrackedRow`'s objects and `RowOffsets` array to update the
`DW_AT_LLVM_stmt_sequence` attributes with the correct offsets.



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