| commit | abdbaff5441e35a6e26f770145b62d73f4a55f48 | [log] [tgz] |
|---|---|---|
| author | alx32 <103613512+alx32@users.noreply.github.com> | Thu Mar 13 02:54:49 2025 -0700 |
| committer | GitHub <noreply@github.com> | Thu Mar 13 02:54:49 2025 -0700 |
| tree | 52303c2d307dcfa5a0e03586515dc7e409ea86a3 | |
| parent | 139add531a5533a7591527a3e6cee7dca0f795c3 [diff] |
[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.
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.