[PATCH] D63429: [DebugInfo] Avoid adding too much indirection to pointer-valued variables

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 07:00:21 PDT 2019


jmorse created this revision.
jmorse added reviewers: aprantl, probinson, vsk.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch addresses PR41675 [0], where a stack-pointer variable is dereferenced too many times by its location expression, presenting a value on the stack as the pointer to the stack.

The difference between a stack *pointer* DBG_VALUE and one that refers to a value on the stack, is currently the indirect flag. In the below, the former is the address of, the latter the value in %stack_loc:

  DBG_VALUE %stack_loc, $noreg, !1, !DIExpression()
  DBG_VALUE %stack_loc, 0, !1, !DIExpression()

When the prologepilog pass runs, the stack references are replaced with complex expression opcodes:

  DBG_VALUE $rsp, $noreg, !1, !DIExpression(DW_OP_plus_uconst, 4)
  DBG_VALUE $rsp, 0, !1, !DIExpression(DW_OP_plus_uconst, 4)

Unfortunately, the DWARF backend interprets both of these as being memory locations. For the second DBG_VALUE this is because it's explicitly indirect, but for the first it's because there's a complex expression without DW_OP_stack_value.

Get around this by detecting empty-to-non-empty DIExpression transitions in prologepilog, and adding DW_OP_stack_value to them. This ensures that pointers-to-stack-locs are interpreted as implicit locations, which is what they are.

For the edge case where the offset is zero and the location could be a register location, DIExpression::prepend will still generate opcodes, and thus DW_OP_stack_value must still be added.

[0] https://bugs.llvm.org/show_bug.cgi?id=41675


Repository:
  rL LLVM

https://reviews.llvm.org/D63429

Files:
  lib/CodeGen/PrologEpilogInserter.cpp
  test/DebugInfo/MIR/X86/prolog-epilog-indirection.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63429.205062.patch
Type: text/x-patch
Size: 7997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190617/b90e12a4/attachment.bin>


More information about the llvm-commits mailing list