Pointers can describe where a variable's bytes live (regions in stack, storage, memory, ...), and the expression grammar can compute positions ($sum, $read, $keccak256, ...). But there is no form that says: "this variable currently has no allocation at all — its value equals this expression".
Optimizing compilers need this constantly. After rematerialization or expression folding, a source variable may have no region anywhere, while its value is still perfectly recoverable from other live state, e.g.:
- a constant folded into every use site (value = literal 42),
let x := add(a, 1) eliminated, with a still live (value = a + 1),
- a value recomputable from a storage slot that is still intact.
DWARF handles this with expression-based location descriptions, with a stack-machine expression (see e.g. https://www.hitzhangjie.pro/debugger101-en.io/8-dwarf/4-die/2-desc-locations.html) terminated by DW_OP_stack_value, meaning "the computed result is the value, there is no address". Without an equivalent, the only honest thing a producer can emit for such variables is "unavailable", which loses debugging quality exactly where optimizations kick in.
The expression grammar seems to already contain most of the machinery; what is missing is a schema form marking the result as the value itself rather than a position. A minimal sketch:
{ "value": <expression> }
allowed wherever a variable's pointer goes in a program context (perhaps not inside region collections, since it denotes no data range).
Context: we hit this in the Solidity compiler's ethdebug work (solc #16780 PR) — we currently model these variables with a "computed" phase that admits the value is recomputable in principle but cannot carry the recipe.
Pointers can describe where a variable's bytes live (regions in stack, storage, memory, ...), and the expression grammar can compute positions ($sum, $read, $keccak256, ...). But there is no form that says: "this variable currently has no allocation at all — its value equals this expression".
Optimizing compilers need this constantly. After rematerialization or expression folding, a source variable may have no region anywhere, while its value is still perfectly recoverable from other live state, e.g.:
let x := add(a, 1)eliminated, withastill live (value = a + 1),DWARF handles this with expression-based location descriptions, with a stack-machine expression (see e.g. https://www.hitzhangjie.pro/debugger101-en.io/8-dwarf/4-die/2-desc-locations.html) terminated by
DW_OP_stack_value, meaning "the computed result is the value, there is no address". Without an equivalent, the only honest thing a producer can emit for such variables is "unavailable", which loses debugging quality exactly where optimizations kick in.The expression grammar seems to already contain most of the machinery; what is missing is a schema form marking the result as the value itself rather than a position. A minimal sketch:
allowed wherever a variable's pointer goes in a program context (perhaps not inside region collections, since it denotes no data range).
Context: we hit this in the Solidity compiler's
ethdebugwork (solc #16780 PR) — we currently model these variables with a "computed" phase that admits the value is recomputable in principle but cannot carry the recipe.