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 @@ -648,6 +648,10 @@ continue; } + // Ignore DBG_VALUEs and other meta infos + if (MI->isMetaInstruction()) + continue; + // Clobber any earlyclobber regs first. for (const MachineOperand &MO : MI->operands()) if (MO.isReg() && MO.isEarlyClobber()) { @@ -846,6 +850,10 @@ } } + // Ignore DBG_VALUEs and other meta infos + if (MI->isMetaInstruction()) + continue; + // Invalidate any earlyclobber regs first. for (const MachineOperand &MO : MI->operands()) if (MO.isReg() && MO.isEarlyClobber()) { diff --git a/llvm/test/CodeGen/X86/machine-cp-clobbers.mir b/llvm/test/CodeGen/X86/machine-cp-clobbers.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/machine-cp-clobbers.mir @@ -0,0 +1,17 @@ +# RUN: llc -mtriple=x86_64 -run-pass=machine-cp %s -o - | FileCheck %s + +--- +name: dont_clobber_register_in_dbg_value +tracksRegLiveness: false +body: | + bb.0: + ; CHECK-LABEL: name: dont_clobber_register_in_dbg_value + ; CHECK: renamable $rbx = LEA64r $rax, 1, $noreg, 8, $noreg + ; CHECK: DBG_VALUE $rbp, $noreg + ; CHECK: DBG_VALUE $noreg, $noreg + renamable $rbx = LEA64r $rax, 1, $noreg, 8, $noreg + DBG_VALUE $rbp, $noreg + renamable $rbx = COPY killed renamable $rbp + DBG_VALUE $noreg, $noreg + +...