diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -866,6 +866,8 @@ if (!MO.getReg()) continue; + if (MO.isDebug()) + continue; if (MO.isDef()) Tracker.invalidateRegister(MO.getReg().asMCReg(), *TRI); diff --git a/llvm/test/CodeGen/X86/machine-copy-dbgvalue.mir b/llvm/test/CodeGen/X86/machine-copy-dbgvalue.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/machine-copy-dbgvalue.mir @@ -0,0 +1,18 @@ +# RUN: llc -mtriple=i686-- -run-pass machine-cp -verify-machineinstrs -o - %s | FileCheck %s + + +--- +# Test that machine copy propagation ignores DBG_VALUE +# CHECK-LABEL: name: foo +# CHECK: bb.0: +# CHECK-NEXT: $rax = MOV64ri 31 +# CHECK-NEXT: DBG_VALUE $rcx, $noreg +# CHECK-NEXT: RETQ implicit killed $rax +name: foo +body: | + bb.0: + renamable $rcx = MOV64ri 31 + DBG_VALUE $rcx, $noreg + $rax = COPY renamable killed $rcx + RETQ implicit killed $rax +...