[RFC] Draft Two-Level Line Tables Implementation

Draft Review: ⚙ D152708 [RFC][Draft] Enable primitive support for Two-Level Line Tables in LLVM

We (Sony) have created a small implementation of the Two-Level Line Tables (TLLT) proposal[0] in LLVM, adding basic support for printing and parsing TLLT to llc, llvm-dwarfdump, and lldb. This was done as an experiment to see whether it would be possible to do so and whether it would provide any immediate benefits. With these changes, we are able to compile a simple single-source C program containing an inlined function call, and with llvm-dwarfdump we can see inlined callsites in the line table and each inlined instruction displaying a reference to the callsite it was inlined at. In addition, in LLDB we are able to set a breakpoint on the line of the inlined call, resulting in the debugger stepping onto the first inlined instruction of the function. Our implementation is simple, narrow, and comprises of many hacks to get the minimum functioning input and output, particularly in LLDB (which we have no real experience with).

This is not intended as a proposal for our patch to be merged into LLVM as-is, and we do not currently have any plans to implement a complete version of the TLLT proposal in LLVM. However, as there may be developers who have some interest in this proposal for one reason or another, we have decided to make our brief experiment available to provide a concrete example of TLLT as this patch is, to my knowledge, the only opensource implementation of the current TLLT proposal. Currently, I am of the opinion that TLLT is not necessary for improved breakpoint and attribution behaviour, as other line table extensions (such as Location View Numbering[1]) could achieve the same results and more. If there is any specific desire for a complete TLLT implementation however, then this post and the accompanying patch should be a good starting point for further discussion.

[0] DWARF Issue: Two-Level Line Tables
[1] DWARF Issue: Location View Numbering


I mentioned on the review thread, but maybe it’s better discussed here.

Does location view numbering allow for correct backtraces with inlined frames using only the line table? Or does it only allow for the extra step when going into/out of an inlined function? (like you could step to the call site, then step to the start of the function and observe the right variables in scope/with their correct values - but you wouldn’t actually see the outer frame once you’re inside the inlined code?)


As written it does not, but I believe the Context extension or some variation could be combined with Location View Numbering (or added independently, as long as it also explicitly enables a 1:many mapping from instructions to source locations) without requiring the new line table format.

1 Like