When updating a tSpill/tRestore instruction to be a tSTRr/tLDRr, correctly

set up the source operands. The original instr has an immediate operand that
should be replaced with the frame reg operand rather than just adding the
reg operand. Previously, the instruction ended up with too many operands
causing an assert() when adding the default predicate. rdar://8825456

llvm-svn: 123387
This commit is contained in:
Jim Grosbach 2011-01-13 19:16:48 +00:00
parent 6aa35206e7
commit 767dfbf685

View File

@ -659,8 +659,9 @@ Thumb1RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
MI.setDesc(TII.get(UseRR ? ARM::tLDRr : ARM::tLDRi)); MI.setDesc(TII.get(UseRR ? ARM::tLDRr : ARM::tLDRi));
MI.getOperand(i).ChangeToRegister(TmpReg, false, false, true); MI.getOperand(i).ChangeToRegister(TmpReg, false, false, true);
if (UseRR) if (UseRR)
// Use [reg, reg] addrmode. // Use [reg, reg] addrmode. Replace the immediate operand w/ the frame
MI.addOperand(MachineOperand::CreateReg(FrameReg, false)); // register. The offset is already handled in the vreg value.
MI.getOperand(i+1).ChangeToRegister(FrameReg, false, false, false);
} else if (Desc.mayStore()) { } else if (Desc.mayStore()) {
VReg = MF.getRegInfo().createVirtualRegister(ARM::tGPRRegisterClass); VReg = MF.getRegInfo().createVirtualRegister(ARM::tGPRRegisterClass);
bool UseRR = false; bool UseRR = false;
@ -678,8 +679,10 @@ Thumb1RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
*this, dl); *this, dl);
MI.setDesc(TII.get(UseRR ? ARM::tSTRr : ARM::tSTRi)); MI.setDesc(TII.get(UseRR ? ARM::tSTRr : ARM::tSTRi));
MI.getOperand(i).ChangeToRegister(VReg, false, false, true); MI.getOperand(i).ChangeToRegister(VReg, false, false, true);
if (UseRR) // Use [reg, reg] addrmode. if (UseRR)
MI.addOperand(MachineOperand::CreateReg(FrameReg, false)); // Use [reg, reg] addrmode. Replace the immediate operand w/ the frame
// register. The offset is already handled in the vreg value.
MI.getOperand(i+1).ChangeToRegister(FrameReg, false, false, false);
} else { } else {
assert(false && "Unexpected opcode!"); assert(false && "Unexpected opcode!");
} }