Skip to content
Snippets Groups Projects
Commit 00f07dec authored by Jakob Stoklund Olesen's avatar Jakob Stoklund Olesen
Browse files

Constrain register classes in TailDup.

When rewriting operands, make sure the new registers have a compatible
register class.

llvm-svn: 157163
parent 8eb05fd0
No related branches found
No related tags found
No related merge requests found
...@@ -272,8 +272,8 @@ TailDuplicatePass::TailDuplicateAndUpdate(MachineBasicBlock *MBB, ...@@ -272,8 +272,8 @@ TailDuplicatePass::TailDuplicateAndUpdate(MachineBasicBlock *MBB,
continue; continue;
unsigned Dst = Copy->getOperand(0).getReg(); unsigned Dst = Copy->getOperand(0).getReg();
unsigned Src = Copy->getOperand(1).getReg(); unsigned Src = Copy->getOperand(1).getReg();
MachineRegisterInfo::use_iterator UI = MRI->use_begin(Src); if (MRI->hasOneNonDBGUse(Src) &&
if (++UI == MRI->use_end()) { MRI->constrainRegClass(Src, MRI->getRegClass(Dst))) {
// Copy is the only use. Do trivial copy propagation here. // Copy is the only use. Do trivial copy propagation here.
MRI->replaceRegWith(Dst, Src); MRI->replaceRegWith(Dst, Src);
Copy->eraseFromParent(); Copy->eraseFromParent();
...@@ -429,8 +429,10 @@ void TailDuplicatePass::DuplicateInstruction(MachineInstr *MI, ...@@ -429,8 +429,10 @@ void TailDuplicatePass::DuplicateInstruction(MachineInstr *MI,
AddSSAUpdateEntry(Reg, NewReg, PredBB); AddSSAUpdateEntry(Reg, NewReg, PredBB);
} else { } else {
DenseMap<unsigned, unsigned>::iterator VI = LocalVRMap.find(Reg); DenseMap<unsigned, unsigned>::iterator VI = LocalVRMap.find(Reg);
if (VI != LocalVRMap.end()) if (VI != LocalVRMap.end()) {
MO.setReg(VI->second); MO.setReg(VI->second);
MRI->constrainRegClass(VI->second, MRI->getRegClass(Reg));
}
} }
} }
PredBB->insert(PredBB->instr_end(), NewMI); PredBB->insert(PredBB->instr_end(), NewMI);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment