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

LTO: Preserve input origins before SCC unification for DWARF accuracy

LTO saves input origins before SCC unification to ensure correct DWARF information after tree replacements.

This commit improves LTO’s handling of DWARF debug information by preserving input DIE references before SCC unification. When an instance’s origin tree is replaced due to SCC unification or prevailing-declaration, the original origin can be lost. This change saves these origins by reader-cache index and resolves them later for accurate DWARF generation, ensuring that the debugger can correctly trace entities back to their source inputs even after transformations.

In Details

This commit addresses PR126348 by enhancing the LTO streamer's input handling. It introduces mechanisms (lto_die_ref, lto_pending_origin_ref) within data_in to save DIE references and pending origins using a reader-cache index before potential tree replacements occur during SCC unification. These saved origins are then explicitly written in WPA and incremental-link outputs, ensuring they are available for accurate DWARF registration during late-stage processing, rather than being derived from potentially altered merged trees.

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.
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.
DWARF
A standardized debugging data format used by many compilers and debuggers to represent information about program symbols, types, and structure.
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.
Filed Under: ltodwarfdebugging