]> granicus.if.org Git - llvm/commitdiff
[CodeGen] Ignore debug uses in MachineCopyPropagation
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Wed, 11 Jul 2018 13:30:27 +0000 (13:30 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Wed, 11 Jul 2018 13:30:27 +0000 (13:30 +0000)
Debug uses should not count as real uses, since the presence of debug
information could affect the generated code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336803 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineCopyPropagation.cpp
test/CodeGen/X86/machine-cp-debug.mir [new file with mode: 0644]

index d3bdc772ae4c6b03ef7dbae711e3f9d8e1f646c7..3bf8147a06c39243c3f8ff1a4c193d4289c01efc 100644 (file)
@@ -517,7 +517,7 @@ void MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
       if (MO.isDef() && !MO.isEarlyClobber()) {
         Defs.push_back(Reg);
         continue;
-      } else if (MO.readsReg())
+      } else if (!MO.isDebug() && MO.readsReg())
         ReadRegister(Reg);
     }
 
diff --git a/test/CodeGen/X86/machine-cp-debug.mir b/test/CodeGen/X86/machine-cp-debug.mir
new file mode 100644 (file)
index 0000000..a7fcd98
--- /dev/null
@@ -0,0 +1,23 @@
+# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass=machine-cp %s -o - | FileCheck %s
+
+# Machine copy propagation can remove dead copies. Make sure that the
+# DBG_VALUE does not keep the copy alive.
+#
+# CHECK-NOT: $ebx = COPY $eax
+
+--- |
+  define void @fred() {
+    ret void
+  }
+  !1 = !DIExpression()
+...
+
+---
+name: fred
+tracksRegLiveness: true
+body: |
+  bb.0:
+    liveins: $eax
+    $ebx = COPY $eax
+    DBG_VALUE debug-use $ebx, debug-use _, !1, !1
+...