diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp index 4025e296ce09e0b28681f96a77b9b9a6fa565096..d0f251ed63366184a6f0984935c7b1cc984f998a 100644 --- a/llvm/lib/CodeGen/MachineVerifier.cpp +++ b/llvm/lib/CodeGen/MachineVerifier.cpp @@ -1072,10 +1072,24 @@ void MachineVerifier::verifyLiveIntervals() { << MBBStartIdx << '\n'; } else if (TargetRegisterInfo::isVirtualRegister(LI.reg) && !MI->readsVirtualRegister(LI.reg)) { - // FIXME: Should we require a kill flag? - report("Instruction killing live segment doesn't read register", MI); - I->print(*OS); - *OS << " in " << LI << '\n'; + // A live range can end with either a redefinition, a kill flag on a + // use, or a dead flag on a def. + // FIXME: Should we check for each of these? + bool hasDeadDef = false; + for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), + MOE = MI->operands_end(); MOI != MOE; ++MOI) { + if (MOI->isReg() && MOI->isDef() && MOI->isDead()) { + hasDeadDef = true; + break; + } + } + + if (!hasDeadDef) { + report("Instruction killing live segment neither defines nor reads " + "register", MI); + I->print(*OS); + *OS << " in " << LI << '\n'; + } } }