diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp --- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp @@ -2655,10 +2655,15 @@ void PPCInstrInfo::fixupIsDeadOrKill(MachineInstr &StartMI, MachineInstr &EndMI, unsigned RegNo) const { - - // Instructions between [StartMI, EndMI] should be in same basic block. - assert((StartMI.getParent() == EndMI.getParent()) && - "Instructions are not in same basic block"); + // Conservatively clear kill flag for the register if the instructions are in + // different basic blocks, because the kill flag may no longer be right. There + // is no need to bother with dead flags since defs with no uses will be + // handled by DCE. + MachineRegisterInfo &MRI = StartMI.getParent()->getParent()->getRegInfo(); + if ((StartMI.getParent() != EndMI.getParent())) { + MRI.clearKillFlags(RegNo); + return; + } bool IsKillSet = false; diff --git a/llvm/test/CodeGen/PowerPC/fixup-kill-dead-flag-crash.mir b/llvm/test/CodeGen/PowerPC/fixup-kill-dead-flag-crash.mir new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/fixup-kill-dead-flag-crash.mir @@ -0,0 +1,21 @@ +# RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -verify-machineinstrs -start-before ppc-mi-peepholes \ +# RUN: -stop-after ppc-mi-peepholes %s -o - | FileCheck %s + +--- +name: test +#CHECK : name : test +tracksRegLiveness: true +body: | + bb.0.entry: + liveins: $x3 + %0:g8rc = COPY $x3 + %1:gprc = COPY %0.sub_32:g8rc + %2:g8rc = LI8 63 + + bb.1: + %3:gprc = COPY %2.sub_32:g8rc + ; CHECK: %4:gprc = LI 0 + %4:gprc = XORI killed %3:gprc, 63 + STW killed %4:gprc, %4:gprc, 100 + BLR8 implicit $lr8, implicit $rm +...