[PATCH] D54716: [WIP][DebugInfo] Allow MachineCopyPropagate to update DebugInfo RegUses

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 19 11:31:03 PST 2018


jmorse created this revision.
Herald added a subscriber: llvm-commits.

This is a work-in-progress related to PR38754 [0], uploaded for visibility rather than review.

The purpose of the patch is to kill one use of changeDebugValuesDefReg and thus avoid using the related MachineInstr::collectDebugValues method. It constitutes an alternate fix for PR38773: rather than manually updating the registers that DBG_VALUEs refer to after MCP fires, instead mark DBG_VALUE register uses as being renamable. My understanding is that there's no functional (i.e. real instructions) reason why DBG_VALUEs can't be renamable, and it'll reduce the probability that less-well-written passes will behave differently when DBG_VALUEs are present. DBG_VALUE reg uses of the MCP'd register are then updated just like any other insn.

Either way seems fine to me; as mentioned though I'll upload a patch in a moment that messes with collectDebugValues, hence this option may be preferable.

[0] https://bugs.llvm.org/show_bug.cgi?id=38754


Repository:
  rL LLVM

https://reviews.llvm.org/D54716

Files:
  lib/CodeGen/LiveDebugVariables.cpp
  lib/CodeGen/MachineCopyPropagation.cpp
  test/CodeGen/MIR/X86/pr38773.mir


Index: test/CodeGen/MIR/X86/pr38773.mir
===================================================================
--- test/CodeGen/MIR/X86/pr38773.mir
+++ test/CodeGen/MIR/X86/pr38773.mir
@@ -98,7 +98,7 @@
     renamable $ecx = COPY $eax
     ; CHECK:        IDIV32r killed renamable $ecx
     ; CHECK-NEXT:   DBG_VALUE $eax, $noreg, !12, !DIExpression(), debug-location !13
-    DBG_VALUE $ecx, $noreg, !12, !DIExpression(), debug-location !13
+    DBG_VALUE renamable $ecx, $noreg, !12, !DIExpression(), debug-location !13
     $eax = COPY killed renamable $ecx
     RET 0, $eax
 
Index: lib/CodeGen/MachineCopyPropagation.cpp
===================================================================
--- lib/CodeGen/MachineCopyPropagation.cpp
+++ lib/CodeGen/MachineCopyPropagation.cpp
@@ -307,6 +307,11 @@
 bool MachineCopyPropagation::isForwardableRegClassCopy(const MachineInstr &Copy,
                                                        const MachineInstr &UseI,
                                                        unsigned UseIdx) {
+  // Debug values have no register classes to be examined
+  if (UseI.isDebugValue()) {
+    assert(UseI.getOperand(UseIdx).isReg());
+    return true;
+  }
 
   unsigned CopySrcReg = Copy.getOperand(1).getReg();
 
@@ -612,7 +617,7 @@
 
       // Update matching debug values.
       assert(MaybeDead->isCopy());
-      MaybeDead->changeDebugValuesDefReg(MaybeDead->getOperand(1).getReg());
+      //MaybeDead->changeDebugValuesDefReg(MaybeDead->getOperand(1).getReg());
 
       MaybeDead->eraseFromParent();
       Changed = true;
Index: lib/CodeGen/LiveDebugVariables.cpp
===================================================================
--- lib/CodeGen/LiveDebugVariables.cpp
+++ lib/CodeGen/LiveDebugVariables.cpp
@@ -1087,6 +1087,7 @@
         // index is no longer available. That means the user value is in a
         // non-existent sub-register, and %noreg is exactly what we want.
         Loc.substPhysReg(VRM.getPhys(VirtReg), TRI);
+        Loc.setIsRenamable();
       } else if (VRM.getStackSlot(VirtReg) != VirtRegMap::NO_STACK_SLOT) {
         // Retrieve the stack slot offset.
         unsigned SpillSize;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54716.174654.patch
Type: text/x-patch
Size: 2166 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181119/33bd9e5f/attachment.bin>


More information about the llvm-commits mailing list