[PATCH] D27550: Fix LLVM's use of DW_OP_bit_piece in DWARF expressions.

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 15:08:34 PST 2016


aprantl created this revision.
aprantl added reviewers: dblaikie, probinson.
aprantl added a subscriber: llvm-commits.
aprantl set the repository for this revision to rL LLVM.

This is a follow-up to the discussion in 
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20161114/405934.html

Apologies for the long patch. The good news is that most changes are deleting code.

LLVM's use of DW_OP_bit_piece is incorrect and a based on a
misunderstanding of the wording in the DWARF specification. The offset
argument of DW_OP_bit_piece refers to the offset into the location
that is on the top of the DWARF expression stack, and not an offset
into the source variable. This has since also been clarified in the
DWARF specification.

This patch fixes all uses of DW_OP_bit_piece to emit the correct
offset and simplifies the DwarfExpression class to semi-automaticaly
emit empty DW_OP_pieces to adjust the offset of the source variable,
thus simplifying the code using DwarfExpression.

While this is an incompatible bugfix, in practice I don't expect this
to be much of a problem since LLVM's old interpretation and the
correct interpretation of DW_OP_bit_piece differ only when there are
gaps in the fragmented locations of the described variables or if
individual fragments are smaller than a byte. LLDB at least won't
interpret locations with gaps in them at all because is has no way to present
undefined bits in a variable, and there is a high probability that an
old-form expression will be malformed when interpreted correctly,
because the DW_OP_bit_piece offset will be outside of the location at
the top of the stack.

As a nice side-effect, this patch enables us to use a more efficient
encoding for subregisters: In order to express a sub-register at a
non-zero offset we now use a DW_OP_bit_piece instead of shifting the
value into place manually.

This patch also adds missing test coverage for code paths that weren't
exercised before.


Repository:
  rL LLVM

https://reviews.llvm.org/D27550

Files:
  include/llvm/CodeGen/AsmPrinter.h
  lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  lib/CodeGen/AsmPrinter/DwarfExpression.cpp
  lib/CodeGen/AsmPrinter/DwarfExpression.h
  lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  lib/CodeGen/AsmPrinter/DwarfUnit.h
  test/DebugInfo/AArch64/frameindices.ll
  test/DebugInfo/MIR/X86/bit-piece-dh.mir
  test/DebugInfo/X86/PR26148.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27550.80673.patch
Type: text/x-patch
Size: 29701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/59a9fe85/attachment.bin>


More information about the llvm-commits mailing list