[PATCH] D58238: [DebugInfo] MachineSink: Insert undef DBG_VALUEs when sinking instructions, try to forward copies

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 14 07:56:56 PST 2019

jmorse created this revision.
jmorse added reviewers: aprantl, bjope, vsk.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
jmorse added a parent revision: D58191: [DebugInfo] Make postra sinking of DBG_VALUEs safe in the presence of subregisters.

When we sink DBG_VALUEs at the moment, we simply move the DBG_VALUE instruction to below the sunk instruction. However, we should also mark the variable as being undef at the source location, to terminate any earlier variable location. This patch does that -- plus, if the instruction being sunk is a copy, it attempts to propagate the copy through the DBG_VALUE, replacing the destination with the source.

To avoid any kind of subregister shennanigans, vreg copy propagation only happens if all the subregisters agree; for physical registers we only propagate if the DBG_VALUE operand is the same as the destination of the copy. So:

  %1 = COPY %0

Would copy-prop, while

  %1 = COPY %0
  DBG_VALUE %1.subreg_8bit

Would not. Additional analysis might determine this to be safe, but I haven't implemented it here.

Likewise after regalloc:

  $eax = COPY $ecx
  DBG_VALUE $eax

Would constant-prop, while

  $ax = $cx
  DBG_VALUE $eax

Would not.

With this patch, building clang-3.4 yields a fractional number more number of covered variables, and roughly 0.5% more scope-bytes coverage.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58238.186844.patch
Type: text/x-patch
Size: 8335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190214/e91e3155/attachment.bin>

More information about the llvm-commits mailing list