llvm-project/llvm/lib/CodeGen/AsmPrinter
Adrian Prantl 8fafb8d378 Fix LLVM's use of DW_OP_bit_piece in DWARF expressions.
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 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.

<rdar://problem/29335809>
Differential Revision: https://reviews.llvm.org/D27550

llvm-svn: 289266
2016-12-09 20:43:40 +00:00
..
ARMException.cpp Move most EH from MachineModuleInfo to MachineFunction 2016-12-01 19:32:15 +00:00
AddressPool.cpp Move helpers into anonymous namespaces. NFC. 2016-08-06 11:13:10 +00:00
AddressPool.h One more batch of self-containing headers. 2016-01-27 19:29:56 +00:00
AsmPrinter.cpp Revert "[CodeGen] Fix invalid DWARF info on Win64" 2016-12-08 01:56:23 +00:00
AsmPrinterDwarf.cpp Fix LLVM's use of DW_OP_bit_piece in DWARF expressions. 2016-12-09 20:43:40 +00:00
AsmPrinterHandler.h Extract the method to begin and end a fragment in AsmPrinterHandler in their own method. NFC 2016-02-26 20:30:37 +00:00
AsmPrinterInlineAsm.cpp Recognize ${:uid} escapes in intel syntax inline asm 2016-11-29 00:29:27 +00:00
ByteStreamer.h [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
CMakeLists.txt [CMake] NFC. Updating CMake dependency specifications 2016-11-17 04:36:50 +00:00
CodeViewDebug.cpp Revert "[CodeGen] Fix invalid DWARF info on Win64" 2016-12-08 01:56:23 +00:00
CodeViewDebug.h Move VariableDbgInfo from MachineModuleInfo to MachineFunction 2016-11-30 23:48:50 +00:00
DIE.cpp Plug another leak in the DWARF unittests, DIEInlineStrings are never destroyed. 2016-12-09 13:33:41 +00:00
DIEHash.cpp Make a DWARF generator so we can unit test DWARF APIs with gtest. 2016-12-08 01:03:48 +00:00
DIEHash.h Apply another batch of fixes from clang-tidy's performance-unnecessary-value-param. 2016-06-17 20:41:14 +00:00
DbgValueHistoryCalculator.cpp CodeGen: Give MachineBasicBlock::reverse_iterator a handle to the current MI 2016-09-11 18:51:28 +00:00
DbgValueHistoryCalculator.h One more batch of self-containing headers. 2016-01-27 19:29:56 +00:00
DebugHandlerBase.cpp [DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation 2016-12-05 18:04:47 +00:00
DebugHandlerBase.h [DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation 2016-12-05 18:04:47 +00:00
DebugLocEntry.h [DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation 2016-12-05 18:04:47 +00:00
DebugLocStream.cpp AsmPrinter: Don't emit empty .debug_loc entries 2015-06-21 16:54:56 +00:00
DebugLocStream.h AsmPrinter: Don't emit empty .debug_loc entries 2015-06-21 16:54:56 +00:00
DwarfAccelTable.cpp This change removes the dependency on DwarfDebug that was used for DW_FORM_ref_addr by making a new DIEUnit class in DIE.cpp. 2016-12-01 18:56:29 +00:00
DwarfAccelTable.h Remove LLVM_CONSTEXPR. 2016-10-23 19:39:16 +00:00
DwarfCFIException.cpp Move most EH from MachineModuleInfo to MachineFunction 2016-12-01 19:32:15 +00:00
DwarfCompileUnit.cpp Fix LLVM's use of DW_OP_bit_piece in DWARF expressions. 2016-12-09 20:43:40 +00:00
DwarfCompileUnit.h [debug info] Minor cleanup from D27170/r288399 2016-12-01 21:59:09 +00:00
DwarfDebug.cpp Fix LLVM's use of DW_OP_bit_piece in DWARF expressions. 2016-12-09 20:43:40 +00:00
DwarfDebug.h [DIExpression] Introduce a dedicated DW_OP_LLVM_fragment operation 2016-12-05 18:04:47 +00:00
DwarfException.h Extract the method to begin and end a fragment in AsmPrinterHandler in their own method. NFC 2016-02-26 20:30:37 +00:00
DwarfExpression.cpp Fix LLVM's use of DW_OP_bit_piece in DWARF expressions. 2016-12-09 20:43:40 +00:00
DwarfExpression.h Fix LLVM's use of DW_OP_bit_piece in DWARF expressions. 2016-12-09 20:43:40 +00:00
DwarfFile.cpp Make a DWARF generator so we can unit test DWARF APIs with gtest. 2016-12-08 01:03:48 +00:00
DwarfFile.h Make a DWARF generator so we can unit test DWARF APIs with gtest. 2016-12-08 01:03:48 +00:00
DwarfStringPool.cpp
DwarfStringPool.h Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
DwarfUnit.cpp Fix LLVM's use of DW_OP_bit_piece in DWARF expressions. 2016-12-09 20:43:40 +00:00
DwarfUnit.h Fix LLVM's use of DW_OP_bit_piece in DWARF expressions. 2016-12-09 20:43:40 +00:00
EHStreamer.cpp Move most EH from MachineModuleInfo to MachineFunction 2016-12-01 19:32:15 +00:00
EHStreamer.h Extract the method to begin and end a fragment in AsmPrinterHandler in their own method. NFC 2016-02-26 20:30:37 +00:00
ErlangGCPrinter.cpp Move most user of TargetMachine::getDataLayout to the Module one 2015-07-16 06:11:10 +00:00
LLVMBuild.txt Prune unused libdeps. 2016-12-08 15:28:02 +00:00
OcamlGCPrinter.cpp Use the range variant of find instead of unpacking begin/end 2016-08-11 22:21:41 +00:00
WinException.cpp Don't emit .seh_handler directives for any cleanup funclets 2016-12-08 20:38:46 +00:00
WinException.h [WinEH] Move WinEHFuncInfo from MachineModuleInfo to MachineFunction 2015-11-17 21:10:25 +00:00