mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Handle dead defs in the if converter.
We had code such as this: r2 = ... t2Bcc label1: ldr ... r2 label2; return r2<dead, def> The if converter was transforming this to r2<def> = ... return [pred] r2<dead,def> ldr <r2, kill> return which fails the machine verifier because the ldr now reads from a dead def. The fix here detects dead defs in stepForward and passes them back to the caller in the clobbers list. The caller then clears the dead flag from the def is the value is live. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236660 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user