GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
lto

LTO: Preserve input DIE references for accurate DWARF generation

LTO preserves input DIE references in declaration states to ensure correct DWARF generation after SCC unification.

This change enhances Link-Time Optimization (LTO) by preserving input Debugging Information Entry (DIE) references within declaration states. Previously, SCC unification or prevailing-declaration replacement could cause these references to resolve to incorrect input trees, leading to faulty DWARF output. The fix ensures that slot-to-DIE references are retained with each declaration state and used during body reading to register input origins for late DWARF generation, improving debug information accuracy.

In Details

This commit addresses PR126348 by modifying the LTO stream functionality. It introduces lto_decl_origin_ref and stores these references within lto_in_decl_state and lto_out_decl_state. These saved references are crucial for accurately mapping declaration states to their original input DIEs, especially after LTO's SCC unification or prevailing-declaration replacement. This ensures that the generated DWARF debug information correctly reflects the origin of entities, even when their underlying trees are modified or merged.

For Context
LTO
Link-Time Optimization. A build process where optimization is performed not just on individual object files, but also across them during the linking stage, enabling more global optimizations.
DIE
Debugging Information Entry. A record within DWARF debug information that describes a specific entity in the program, such as a variable, function, or type.
DWARF
A standardized debugging data format used by many compilers and debuggers to represent information about program symbols, types, and structure.
SCC unification
In LTO, refers to the process where strongly connected components (SCCs) of the call graph are analyzed and potentially merged or unified to enable cross-module optimizations. This can alter the origin of code entities.
Filed Under: ltodwarfdebugging