[PATCH] D58450: [DebugInfo][MachineCSE] Don't try to copy-propagate debuginfo for every COPY seen

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 20 07:31:27 PST 2019


jmorse created this revision.
jmorse added reviewers: aprantl, bjope, vsk.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.

This patch alters the debug-info salvaging behaviour of MachineCSE, and adds a test for its behaviour (only one opaque test is currently sensitive to MachineCSEs DI salvaging).

In the loop in MachineCSE::PerformTrivialCopyPropagation (see patch), for an arbitrary input instruction, MachineCSE tries to copy-propagate vreg reading operands to expose more CSE opportunities. This is great -- but the current call to changeDebugValuesDefReg then unconditionally rewrites the DBG_VALUE users of the COPY that was propagated. This means that any COPY instruction whose result is the subject of CSE will have its DBG_VALUEs copy-propagated too, even if the COPY lives on, which is a bit overkill. I believe this propagation is only necessary if the COPY is to be deleted -- hence in this patch, the DBG_VALUE updating is moved to only occur if the COPY is deleted.

While we're here, alter changeDebugValuesDefReg to find DBG_VALUEs by enumerating vreg users, which catches DBG_VALUEs that don't immediately follow the COPY. MachineCSE is the only remaining user of this function (assuming D56265 <https://reviews.llvm.org/D56265> makes it in).

I've added a test that stimulates both behaviours -- first where a COPY is deleted (and thus all DBG_VALUE users must update) and one where it doesn't.

A clang-3.4 build with this patch ticks up a fractional amount, and the covered scope bytes ticks down a fraction too. The ticking down is likely because vreg liveness interacting with DBG_VALUEs is still an open problem.


Repository:
  rL LLVM

https://reviews.llvm.org/D58450

Files:
  include/llvm/CodeGen/MachineInstr.h
  lib/CodeGen/MachineCSE.cpp
  lib/CodeGen/MachineInstr.cpp
  test/DebugInfo/MIR/X86/machine-cse.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58450.187579.patch
Type: text/x-patch
Size: 11126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190220/48aec443/attachment.bin>


More information about the llvm-commits mailing list