This patch adds documentation to SourceLevelDebugging.rst that explains how variable location information is compiled from the IR representation down to the end of the codegen pipeline, but avoiding discussion of file formats and encoding.
As far as I'm aware this is all currently undocumented (in html docs at least). There may be much better ways of structuring the added information, and I'm very happy to reorganize/rewrite the text.
Things that I believe this documents:
- How llvm.dbg.value intrinsics map down onto DBG_VALUE instructions
- Several examples of how variable locations should be changed when instruction scheduling moves instructions
- What LiveDebugVariables does
- What LiveDebugValues does
- The rationale behind _why_ LiveDebugValues expands variable location information at a late stage, versus mem2reg encoding lots of information
- The fact that DBG_VALUE changes meaning (I believe!) after LiveDebugValues
- That each block must define all valid variable locations in it by the end of codegen (see discussion in D59431)
What it doesn't explain, and is still a mystery to me:
- _Why_ does LiveDebugVariables do what it does?
I'd also be highly interested in things that are currently uncertain/unknown, but really should be documented. Ideally this page should contain all the rationale behind how debuginfo is designed/operates.
Wdyt of keeping with the title of this patch and calling this 'How variable location metadata is used' (or, transformed)?