[PATCH] D31439: PR32382: Emit complex DWARF expressions with the correct location description kind

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 28 14:09:33 PDT 2017


aprantl created this revision.

This fixes most of PR32382. It does not fix the DWARF 2 expressions yet; that part can be done as a separate, simpler follow-up commit.

The DWARF specification knows 3 kinds of non-empty simple location descriptions:

1. Register location descriptions
  - describe a variable in a register
  - consist of only a DW_OP_reg
2. Memory location descriptions
  - describe the address of a variable
3. Implicit location descriptions
  - describe the value of a variable
  - end with DW_OP_stack_value & friends

The existing DwarfExpression code is pretty much ignorant of these restrictions. This used to not matter because we only emitted very short expressions that we happened to get right by accident.    
This patch makes DwarfExpression aware of the rules defined by the DWARF standard and now chooses the right kind of location description for each expression being emitted.

      

This would have been an NFC commit (for the existing testsuite) if not for the way that clang describes captured block variables. Based on how the previous code in LLVM emitted locations, DW_OP_deref operations that should have come at the end of the expression are put at its beginning. Fixing this means changing the semantics of DIExpression, so this patch bumps the version number of DIExpression and implements a bitcode upgrade for expressions relying on the odd behavior of DW_OP_deref.

      

https://bugs.llvm.org/show_bug.cgi?id=32382
rdar://problem/31205000


https://reviews.llvm.org/D31439

Files:
  include/llvm/IR/DebugInfoMetadata.h
  lib/Bitcode/Reader/MetadataLoader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  lib/CodeGen/AsmPrinter/DwarfExpression.h
  test/Bitcode/DIExpression-deref.ll
  test/Bitcode/DIExpression-deref.ll.bc
  test/DebugInfo/X86/block-capture.ll
  test/DebugInfo/X86/debug-info-block-captured-self.ll
  test/DebugInfo/X86/debug-info-blocks.ll
  test/DebugInfo/X86/dw_op_minus.ll
  test/DebugInfo/X86/dw_op_minus_direct.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31439.93285.patch
Type: text/x-patch
Size: 19957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170328/a90a748f/attachment.bin>


More information about the llvm-commits mailing list