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

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 11:09:25 PDT 2020


StephenTozer created this revision.
StephenTozer added reviewers: aprantl, probinson, vsk, djtodoro, dblaikie.
StephenTozer added a project: debug-info.
Herald added subscribers: llvm-commits, aheejin, hiraditya, dschuff.
Herald added a project: LLVM.

Continuing the work discussed in the RFC[0], this patch implements the actual emission of DWARF from a DBG_VALUE_LIST instruction.

The logic for handling the new instruction is simple in most places; DbgEntityHistoryCalculator has a more complex set of changes since it's more involved with register tracking, and the code for producing DW_AT_location in both DwarfDebug and DwarfExpression also required some heftier work.

Previously, the code in emitDebugLocEntry functioned along the lines of:

1. Emit any fragment info
2. Emit any entry value info
3. Emit the location specified in the DBG_VALUE, e.g. `DW_OP_reg X` or `DW_OP_constu X`
4. Finally call DwarfExpression::addExpression(), which handles the DIExpression (except fragments)

Since there may now be multiple locations scattered throughout the expression, rather than a single location at the front, `addExpression` has been modified to optionally take a lambda that is used to handle `DW_OP_LLVM_arg N`; the lambda is passed in from emitDebugLocEntry, and performs step 3 using the Nth debug operand. Non-list debug values follow the same behaviour as before. DwarfCompileUnit::constructVariableDIEImpl is similar, but simpler.

The alternative to using the lambda would be to move some of the code in DwarfDebug::emitDebugLocEntry directly into DwarfExpr, and passing a list of locations to `addExpression`. The hard part with this is that DwarfDebug and DwarfCompileUnit perform step 3 differently, although it's possible their behaviour can be merged. The purpose of choosing the lambda was to minimize the amount of actual change made, but if the alternative option seems like an objectively good refactor then I'm happy to adjust.

[0] http://lists.llvm.org/pipermail/llvm-dev/2020-February/139376.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83495

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
  llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
  llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
  llvm/test/DebugInfo/X86/dbg_value_list_clobbers.mir
  llvm/test/DebugInfo/X86/dbg_value_list_emission.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83495.276774.patch
Type: text/x-patch
Size: 41044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200709/69e30d82/attachment.bin>


More information about the llvm-commits mailing list