llvm-project/llvm/test/DebugInfo/ARM
David Stenberg 5ffec6deef [DebugInfo] Improve handling of clobbered fragments
Summary:
Currently the DbgValueHistorymap only keeps track of clobbered registers
for the last debug value that it has encountered. This could lead to
preceding register-described debug values living on longer in the
location lists than they should. See PR40283 for an example.  This
patch does not introduce tracking of multiple registers, but changes
the DbgValueHistoryMap structure to allow for that in a follow-up
patch. This patch is not NFC, as it at least fixes two bugs in
DwarfDebug (both are covered in the new clobbered-fragments.mir test):

* If a debug value was clobbered (its End pointer set), the value would
  still be added to OpenRanges, meaning that the succeeding location list
  entries could potentially contain stale values.

* If a debug value was clobbered, and there were non-overlapping
  fragments that were still live after the clobbering, DwarfDebug would
  not create a location list entry starting directly after the
  clobbering instruction. This meant that the location list could have
  a gap until the next debug value for the variable was encountered.

Before this patch, the history map was represented by <Begin, End>
pairs, where a new pair was created for each new debug value. When
dealing with partially overlapping register-described debug values, such
as in the following example:

  DBG_VALUE $reg2, $noreg, !1, !DIExpression(DW_OP_LLVM_fragment, 32, 32)
  [...]
  DBG_VALUE $reg3, $noreg, !1, !DIExpression(DW_OP_LLVM_fragment, 64, 32)
  [...]
  $reg2 = insn1
  [...]
  $reg3 = insn2

the history map would then contain the entries `[<DV1, insn1>, [<DV2, insn2>]`.
This would leave it up to the users of the map to be aware of
the relative order of the instructions, which e.g. could make
DwarfDebug::buildLocationList() needlessly complex. Instead, this patch
makes the history map structure monotonically increasing by dropping the
End pointer, and replacing that with explicit clobbering entries in the
vector. Each debug value has an "end index", which if set, points to the
entry in the vector that ends the debug value. The ending entry can
either be an overlapping debug value, or an instruction which clobbers
the register that the debug value is described by. The ending entry's
instruction can thus either be excluded or included in the debug value's
range. If the end index is not set, the debug value that the entry
introduces is valid until the end of the function.

Changes to test cases:

 * DebugInfo/X86/pieces-3.ll: The range of the first DBG_VALUE, which
   describes that the fragment (0, 64) is located in RDI, was
   incorrectly ended by the clobbering of RAX, which the second
   (non-overlapping) DBG_VALUE was described by. With this patch we
   get a second entry that only describes RDI after that clobbering.

 * DebugInfo/ARM/partial-subreg.ll: This test seems to indiciate a bug
   in LiveDebugValues that is caused by it not being aware of fragments.
   I have added some comments in the test case about that. Also, before
   this patch DwarfDebug would incorrectly include a register-described
   debug value from a preceding block in a location list entry.

Reviewers: aprantl, probinson, dblaikie, rnk, bjope

Reviewed By: aprantl

Subscribers: javed.absar, kristof.beyls, jdoerfert, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D59941

llvm-svn: 358072
2019-04-10 11:28:20 +00:00
..
PR16736.ll
PR26163.ll Remove irrelevant references to legacy git repositories from 2019-01-15 16:18:52 +00:00
big-endian-bitfield.ll
big-endian-dump.ll
bitfield.ll
cfi-eof-prologue.mir test/DebugInfo: Convert some tests to MIR 2018-11-02 01:31:52 +00:00
constant-dbgloc.ll
float-args.ll
float-stack-arg.ll [DebugInfo] Ignore bitcasts when lowering stack arg dbg.values 2019-03-18 11:27:32 +00:00
header.ll
illegal-fragment.ll
line.test
lit.local.cfg
little-endian-dump.ll
lowerbdgdeclare_vla.ll
multiple-constant-uses-drops-dbgloc.ll Remove irrelevant references to legacy git repositories from 2019-01-15 16:18:52 +00:00
partial-subreg.ll [DebugInfo] Improve handling of clobbered fragments 2019-04-10 11:28:20 +00:00
processes-relocations.ll
prologue_end.ll Replace "no-frame-pointer-*" function attributes with "frame-pointer" 2019-01-14 10:55:55 +00:00
s-super-register.ll
salvage-debug-info.ll
sdag-split-arg.ll
sdag-split-arg1.ll MachineOperand/MIParser: Do not print debug-use flag, infer it 2018-10-30 23:28:27 +00:00
selectiondag-deadcode.ll
single-constant-use-preserves-dbgloc.ll Revert "DwarfDebug: Pick next location in case of missing location at block begin" 2018-10-11 23:37:58 +00:00
split-complex.ll [DebugInfo] Normalize common kinds of DWARF sub-expressions. 2018-09-05 10:18:36 +00:00
sroa-complex.ll
tls.ll