diff options
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/IfConversion.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/CodeGen/LivePhysRegs.cpp | 11 |
2 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index 3ac78b25854..5df18fbe199 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -980,10 +980,10 @@ static void UpdatePredRedefs(MachineInstr *MI, LivePhysRegs &Redefs) { // Now add the implicit uses for each of the clobbered values. for (auto Reg : Clobbers) { - const MachineOperand &Op = *Reg.second; // FIXME: Const cast here is nasty, but better than making StepForward // take a mutable instruction instead of const. - MachineInstr *OpMI = const_cast<MachineInstr*>(Op.getParent()); + MachineOperand &Op = const_cast<MachineOperand&>(*Reg.second); + MachineInstr *OpMI = Op.getParent(); MachineInstrBuilder MIB(*OpMI->getParent()->getParent(), OpMI); if (Op.isRegMask()) { // First handle regmasks. They clobber any entries in the mask which @@ -999,6 +999,12 @@ static void UpdatePredRedefs(MachineInstr *MI, LivePhysRegs &Redefs) { continue; } assert(Op.isReg() && "Register operand required"); + if (Op.isDead()) { + // If we found a dead def, but it needs to be live, then remove the dead + // flag. + if (Redefs.contains(Op.getReg())) + Op.setIsDead(false); + } MIB.addReg(Reg.first, RegState::Implicit | RegState::Undef); } } diff --git a/llvm/lib/CodeGen/LivePhysRegs.cpp b/llvm/lib/CodeGen/LivePhysRegs.cpp index b6369275051..eef7643367f 100644 --- a/llvm/lib/CodeGen/LivePhysRegs.cpp +++ b/llvm/lib/CodeGen/LivePhysRegs.cpp @@ -77,8 +77,9 @@ void LivePhysRegs::stepForward(const MachineInstr &MI, if (Reg == 0) continue; if (O->isDef()) { - if (!O->isDead()) - Clobbers.push_back(std::make_pair(Reg, &*O)); + // Note, dead defs are still recorded. The caller should decide how to + // handle them. + Clobbers.push_back(std::make_pair(Reg, &*O)); } else { if (!O->isKill()) continue; @@ -90,8 +91,12 @@ void LivePhysRegs::stepForward(const MachineInstr &MI, } // Add defs to the set. - for (auto Reg : Clobbers) + for (auto Reg : Clobbers) { + // Skip dead defs. They shouldn't be added to the set. + if (Reg.second->isReg() && Reg.second->isDead()) + continue; addReg(Reg.first); + } } /// Prin the currently live registers to OS. |