[PATCH] D68465: [DebugInfo] Trim call-clobbered location list entries when tuning for GDB

David Stenberg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 07:47:54 PDT 2019


dstenb created this revision.
dstenb added reviewers: dblaikie, aprantl, vsk, probinson.
dstenb added a project: debug-info.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This is a patch that mimics GCC's behavior for location list entries
that are clobbered by calls. This is introduced in order to stop
variables that are described by call-clobbered registers and reside in
outer frames from being printable when performing virtual unwinding in
GDB.

GDB has no information about which registers are scratch registers and
which are preserved, but instead relies on the producer to describe
that. One way of solving that would be to emit DW_CFA_undefined
instructions for all scratch registers, but that would result in a lot
of CFI output.

When unwinding to an outer frame, GCC and LLDB subtract one byte from
the return address in order to get the correct scope for the call. GCC
utilizes that by subtracting one byte from the range for all variables
that are clobbered by the call. This means that such variables will be
printed as <optimized out> in GDB when performing virtual unwinding, but
the variables will still be printable when standing on the call before
executing it. This commit introduces the same behavior in LLVM's
location list code. This assumes that a call instruction is larger than
one byte.

LLDB has knowledge about which registers are preserved, so trimming the
ranges in this way is not valuable for LLDB, as far as I can tell. I
have therefore added this as a GDB tuning.

This fixes PR39752.


Repository:
  rL LLVM

https://reviews.llvm.org/D68465

Files:
  llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
  llvm/lib/CodeGen/AsmPrinter/DebugLocStream.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/test/DebugInfo/MIR/ARM/param-reg-const-mix.mir
  llvm/test/DebugInfo/MIR/X86/call-clobbered-entry-value.mir
  llvm/test/DebugInfo/MIR/X86/call-clobbered-split.mir
  llvm/test/DebugInfo/MIR/X86/call-clobbered-values.mir
  llvm/test/DebugInfo/MIR/X86/clobbered-fragments.mir
  llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
  llvm/test/DebugInfo/X86/loclists-dwp.ll
  llvm/test/tools/llvm-dwarfdump/X86/locstats.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68465.223221.patch
Type: text/x-patch
Size: 45937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/30c43150/attachment.bin>


More information about the llvm-commits mailing list