[DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation
authorAdrian Prantl <aprantl@apple.com>
Mon, 5 Dec 2016 18:04:47 +0000 (18:04 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 5 Dec 2016 18:04:47 +0000 (18:04 +0000)
commit941fa7588bbee856a8d3f634c5b88f101089d30f
treea27a566046fe17ba1ab5691911b2468395a91e52
parentfc78d7cb8e5c0c849950fca7d69d81485f3513e1
[DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation
so we can stop using DW_OP_bit_piece with the wrong semantics.

The entire back story can be found here:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20161114/405934.html

The gist is that in LLVM we've been misinterpreting DW_OP_bit_piece's
offset field to mean the offset into the source variable rather than
the offset into the location at the top the DWARF expression stack. In
order to be able to fix this in a subsequent patch, this patch
introduces a dedicated DW_OP_LLVM_fragment operation with the
semantics that we used to apply to DW_OP_bit_piece, which is what we
actually need while inside of LLVM. This patch is complete with a
bitcode upgrade for expressions using the old format. It does not yet
fix the DWARF backend to use DW_OP_bit_piece correctly.

Implementation note: We discussed several options for implementing
this, including reserving a dedicated field in DIExpression for the
fragment size and offset, but using an custom operator at the end of
the expression works just fine and is more efficient because we then
only pay for it when we need it.

Differential Revision: https://reviews.llvm.org/D27361
rdar://problem/29335809

llvm-svn: 288683
52 files changed:
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/include/llvm/Support/Dwarf.h
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.h
llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Support/Dwarf.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Assembler/diexpression.ll
llvm/test/Bitcode/DIExpression-4.0.ll [new file with mode: 0644]
llvm/test/Bitcode/DIExpression-4.0.ll.bc [new file with mode: 0644]
llvm/test/CodeGen/X86/bit-piece-comment.ll
llvm/test/DebugInfo/AArch64/frameindices.ll
llvm/test/DebugInfo/ARM/PR26163.ll
llvm/test/DebugInfo/ARM/split-complex.ll
llvm/test/DebugInfo/ARM/sroa-complex.ll
llvm/test/DebugInfo/COFF/pieces.ll
llvm/test/DebugInfo/Generic/piece-verifier.ll
llvm/test/DebugInfo/X86/PR26148.ll
llvm/test/DebugInfo/X86/array2.ll
llvm/test/DebugInfo/X86/deleted-bit-piece.ll
llvm/test/DebugInfo/X86/nophysreg.ll
llvm/test/DebugInfo/X86/pieces-1.ll
llvm/test/DebugInfo/X86/pieces-2.ll
llvm/test/DebugInfo/X86/pieces-3.ll
llvm/test/DebugInfo/X86/pieces-4.ll
llvm/test/DebugInfo/X86/sroasplit-1.ll
llvm/test/DebugInfo/X86/sroasplit-2.ll
llvm/test/DebugInfo/X86/sroasplit-3.ll
llvm/test/DebugInfo/X86/sroasplit-4.ll
llvm/test/DebugInfo/X86/sroasplit-5.ll
llvm/test/DebugInfo/X86/stack-value-piece.ll
llvm/test/Transforms/Inline/alloca-dbgdeclare.ll
llvm/test/Transforms/SROA/dbg-single-piece.ll
llvm/test/Transforms/Util/split-bit-piece.ll
llvm/unittests/IR/MetadataTest.cpp