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

DWARF: Prefer saved abstract origin for accurate LTO debugging

DWARF output prefers saved abstract origin over potentially redirected tree origin for LTO debugging.

This commit refines DWARF output generation in LTO to correctly handle cases where an instance’s origin tree is replaced. It modifies the external DIE hooks to accept a kind parameter and preferentially use an instance’s saved abstract origin. This ensures that even when SCC unification redirects tree origins, the debugger uses the correct, saved origin information, improving the accuracy of debugging LTO-compiled code, especially for cloned and inlined entities.

In Details

This change to dwarf2out.cc addresses PR126348 by enhancing how abstract origin attributes are handled during LTO. It introduces saved_die_ref and related structures to store the original DIE reference associated with an instance before potential tree replacements. The add_abstract_origin_attribute function now preferentially uses this saved reference, falling back to the origin tree's DIE only if no saved reference exists. This is crucial for correct debugging of entities that undergo cloning or inlining within LTO.

For Context
DWARF
A standardized debugging data format used by many compilers and debuggers to represent information about program symbols, types, and structure.
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.
abstract origin
In the context of DWARF and LTO, refers to the original source location or entity from which a particular piece of code or data ultimately derives, even after transformations like inlining or cloning.
Filed Under: dwarfltodebugging