On Fri, Jan 16, 2026 at 11:01:51AM -0800, David Blaikie wrote:
> Ish. Certainly it's possible to do that - do you have pointers to any
> compilers that do that? My experience with GCC and Clang at least has been
> that there's (perhaps an undocumented) understanding that the locations are
> only considered to be valid after the prologue/before the epilogue, and so
> it's more efficient in terms of DWARF disk space to only describe that area.
GCC for -O0 doesn't do the (sometimes) expensive value tracking and so for
-O0 compiled code the locations are only valid after the prologue/before the
epilogue. In all other -ON/-Os/-Og levels it does the value tracking
(unless asked not to, with -fno-var-tracking or
-fno-var-tracking-assignments) and so should have accurate locations even
within the prologue and epilogue. The tracking is for scalar values or
say SRA optimized aggregates, so for some aggregates it might not be accurate.
There were talks about doing some limited value tracking at -O0, limited
mainly to prologues/epilogues or automatic variables marked with register
keyword (which even for -O0 doesn't often live in memory), but nothing has
been implemented yet. In reality, it isn't just prologues/epilogues, but
e.g. code around declarations of VLAs that can be not accurate at -O0.
And -Og, while exactly due to the value tracking can sometimes be better
than -O0 for debuggability, on the other side doesn't implement yet
artificial extension of variables until end of their lifetime, so compared
to -O0 it can do worse around the end of scopes if nothing needs some
variable or parameter at that point (there is DW_OP_entry_value and the
like, but those work only sometimes, not always).
Jakub
--
Dwarf-discuss mailing list
[email protected]
https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss