diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp --- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -960,7 +960,8 @@ for (MachineBasicBlock::iterator MBBI = AfterMI; MBBI != End;) { auto CopyMI = MBBI++; MBB->splice(InsertPos, MBB, CopyMI); - LIS->handleMove(*CopyMI); + if (!CopyMI->isDebugInstr()) + LIS->handleMove(*CopyMI); InsertPos = CopyMI; } End = std::next(MachineBasicBlock::iterator(MI)); diff --git a/llvm/test/DebugInfo/MIR/X86/mlicm-hoist-post-regalloc.mir b/llvm/test/DebugInfo/MIR/X86/mlicm-hoist-post-regalloc.mir --- a/llvm/test/DebugInfo/MIR/X86/mlicm-hoist-post-regalloc.mir +++ b/llvm/test/DebugInfo/MIR/X86/mlicm-hoist-post-regalloc.mir @@ -1,6 +1,7 @@ --- | ; REQUIRES: asserts ; RUN: llc -start-before=phi-node-elimination -stop-after=machinelicm -debug-only=machinelicm -o - %s | FileCheck %s + ; RUN: llc -start-before=phi-node-elimination -stop-after=machinelicm -debug-only=machinelicm -early-live-intervals -o - %s | FileCheck %s ; Ensure we execute machinelicm post register allocation. ; Line numbers should not be retained when loop invariant instructions are hoisted. ;