[PATCH] D88406: [LiveDebugValues][InstrRef][2/2] Emit entry value variable locations

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 05:10:07 PDT 2020


jmorse created this revision.
jmorse added reviewers: debug-info, djtodoro.
Herald added subscribers: llvm-commits, atanasyan, jrtc27, fedor.sergeev, hiraditya, sdardis, jyknight.
Herald added a project: LLVM.
jmorse requested review of this revision.

Hi,

This patch adds support to the instruction-referencing LiveDebugValues implementation for emitting entry values. It depends on the parent patch to detect when variable locations are clobbered within blocks. Here are the headline figures from the 'PC Ranges covered' field of llvm-locstats:

|                      | VarLocBasedLDV | InstrRefBasedLDV |
| No entry values      | 54%            | 56%              |
| Entry values enabled | 56%            | 61%              |
|

Which, assuming that I've followed the preconditions for emitting entry value locations, is an improvement. Full output of llvm-locstats can be found here [0]. ("Total availability" goes down a little because instr-ref-ldv is a little more aggressive about not propagating variable locations out of their scopes).

The instruction referencing implementations tracking by value rather than location means that we can get around two of the issues with the VarLoc implementation. DBG_VALUE instructions that re-assign the same value to a variable are no longer a problem, because we can "see through" to the value being assigned rather than just the location. We also don't need to do anything special during the dataflow stages: the "variable value problem" doesn't need to know whether a value is available most of the time, and the times it does needs to know are always when entry values need to be terminated (i.e., when differing variable values merge).

The patch modifies the "TransferTracker" class, which is responsible for turning maps of variable => values, and values => locations, into DBG_VALUE instructions within blocks. Two helper functions identify when a variable is an entry value candidate; and when a machine value is an entry value. recoverAsEntryValue tests these two things and emits a DBG_VALUE with an entry value expression if they're true. recoverAsEntryValue is called on two occasions: when a register (or spill slot) is clobbered and we can't find a replacement location for the value it contained; and on entry to a block, if the value isn't live at that point.

This can be tested by using the flag added in the parent patch: -force-instr-ref-livedebugvalues=1. I've added additional RUN lines to a bunch of entry value tests to ensure they work with InstRefBasedLDV: I found these by "git grep"'ing for 'entry_value' and ignoring anything that appeared to be testing call sites. Note that there's one serious modification to a test, kill-entry-value-after-diamond-bbs.mir. My reading of the test is that VarLocBasedLDV has to drop the entry value location because it doesn't know if the DBG_VALUEs in the diamond structure are new value assignments; wheras InstrRefBasedLDV can "see" that the DBG_VALUEs aren't assigning a new value. Advice most welcome: it might be best to update the test to ensure the DBG_VALUEs refer to a different value.

[0] https://gist.github.com/jmorse/a14763d935ef5d20e6e5dc41672c734a


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88406

Files:
  llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
  llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
  llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
  llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
  llvm/test/DebugInfo/MIR/X86/debug-entry-value-operation.mir
  llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/live-debug-values-entry-transfer.mir
  llvm/test/DebugInfo/MIR/X86/livedebugvalues_load_in_loop.mir
  llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
  llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
  llvm/test/DebugInfo/Mips/dw_op_entry_value_32bit.ll
  llvm/test/DebugInfo/Mips/dw_op_entry_value_64bit.ll
  llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
  llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
  llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88406.294663.patch
Type: text/x-patch
Size: 21700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200928/6f32f596/attachment.bin>


More information about the llvm-commits mailing list