diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -1462,6 +1462,11 @@ } while (I != begin() && N > 0); } + // If all the instructions before this in the block are debug instructions, + // skip over them. + while (I != begin() && std::prev(I)->isDebugInstr()) + --I; + // Did we get to the start of the block? if (I == begin()) { // If so, the register's state is definitely defined by the live-in state. diff --git a/llvm/test/CodeGen/X86/leaFixup64.mir b/llvm/test/CodeGen/X86/leaFixup64.mir --- a/llvm/test/CodeGen/X86/leaFixup64.mir +++ b/llvm/test/CodeGen/X86/leaFixup64.mir @@ -1169,7 +1169,7 @@ ; CHECK: NOOP ; CHECK: NOOP ; CHECK: NOOP - ; CHECK: $ebp = LEA64_32r killed $rbp, 1, killed $rax, 0, $noreg + ; CHECK: $ebp = ADD32rr $ebp, $eax, implicit-def $eflags, implicit $rbp, implicit $rax ; CHECK: NOOP ; CHECK: NOOP ; CHECK: NOOP