[DebugInfo] The meaning of dbg.value positions

Hi llvm-dev,

I’ve a few patches up for review that change [0] the placement of dbg.value intrinsics in optimised code, and Paul has pointed out that I might be creating a new interpretation of what their location in the instruction stream means. My question for the list would be whether the new interpretation matches current expectations about how dbg.value intrinsics should work, and if not, will this new interpretation conflict significantly with existing code.

To illustrate the potential change I’ve written up an addition to the “Source Level Debugging” page here [1] describing how I believe these intrinsics should be interpreted. To summarise, in comparison with dbg.declares, dbg.values:

  • Correspond to assignments in the source program,

  • Terminate any location specified by dbg.values that appeared earlier in control flow,

  • Indicate by their position in the IR where in the instruction stream the change in variable location should occur.

The docs patch also writes down a debuginfo objective which I don’t believe is documented elsewhere: when recording variable locations for debuginfo in optimised code, the debugger should never be able to observe a set of variable values that did not appear in the unoptimised program. (And that it’s better for variables to be ``optimised out’’ than to present an inauthentic state of the program).

[0] https://reviews.llvm.org/D58453

[1] https://reviews.llvm.org/D58726