[CodeGen] Fix assertion failure in TwoAddressInstructionPass::rescheduleMIBelowKill

This fixes an assertion failure with -early-live-intervals when trying
to update the live intervals for a debug instruction, which don't even
have slot indexes.

Differential Revision: https://reviews.llvm.org/D113116
This commit is contained in:
Jay Foad 2021-11-03 15:45:24 +00:00
parent 1c81941f19
commit 5c3c7adf3a
2 changed files with 5 additions and 3 deletions

View File

@ -955,12 +955,13 @@ bool TwoAddressInstructionPass::rescheduleMIBelowKill(
nmi = End;
MachineBasicBlock::iterator InsertPos = KillPos;
if (LIS) {
// We have to move the copies first so that the MBB is still well-formed
// when calling handleMove().
// We have to move the copies (and any interleaved debug instructions)
// first so that the MBB is still well-formed when calling handleMove().
for (MachineBasicBlock::iterator MBBI = AfterMI; MBBI != End;) {
auto CopyMI = MBBI++;
MBB->splice(InsertPos, MBB, CopyMI);
LIS->handleMove(*CopyMI);
if (!CopyMI->isDebugOrPseudoInstr())
LIS->handleMove(*CopyMI);
InsertPos = CopyMI;
}
End = std::next(MachineBasicBlock::iterator(MI));

View File

@ -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.
;