[PATCH] D83495: [DebugInfo] Add DWARF emission for DBG_VALUE_LIST

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 4 07:43:25 PST 2021


StephenTozer added a comment.

In D83495#2542005 <https://reviews.llvm.org/D83495#2542005>, @jmorse wrote:

> I agree -- there's some existing misery here [0] where a pass has to be aware that modifying an expression might change the context it's interpreted in, which is an un-necessary complexity.

This is true, and it is something that I intend to change in the next patch after this stack, which will be the replacement of the existing `DBG_VALUE` with the `DBG_VALUE_LIST`. The discussion about this topic on the mailing list was long, but it covers this issue reasonably well I think. Most of the existing ambiguity comes from the fact that DWARF has two ways to reference a register: `DW_OP_reg`, which always means "the variable lives in this register", and `DW_OP_breg` which pushes the value contained in the register onto the expression stack (usually to be interpreted as the address of the live variable), and our method for distinguishing the two is the Directness/Offset flag, which is context-dependent: it reads both the DIExpression and the location operand to see if it should //really// be indirect (and at different points in the program it does this check differently!). The replacement for that flag, that will be added in the aforementioned replacement patch, will not be context-dependent; if it is set to indirect, it will always mean that the result of the DIExpression is a memory address that the variable lives at, regardless of any location operand or the contents of the DIExpression.

Just to jump back to the example that Scott gave as well, the reason why `DW_OP_LLVM_arg` is currently context-dependent is because it follows the existing machine register pipeline. This is done for simplicity's sake, but it is worth noting that it is not currently intended to exist in all contexts. A `DW_OP_LLVM_arg` operator will only currently be produced as part of a DIExpression that ends with `DW_OP_LLVM_stack_value`, which fixes it to always be emitted as `DW_OP_breg` regardless of any other context. The replacement patch will simultaneously enable LLVM_arg operators to exist in non-stack_value expressions, and remove the existing inconsistencies from these cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83495/new/

https://reviews.llvm.org/D83495



More information about the llvm-commits mailing list