Fix rewriting of PHI nodes.

Could someone more familiar with machine-level stuff review this for me?


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44005 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2007-11-12 02:13:07 +00:00
parent 7de5a94099
commit e6e1384c57

View File

@ -52,16 +52,27 @@ MachineBasicBlock* SplitCriticalMachineEdge(MachineBasicBlock* src,
break;
}
// Scan the operands of this branch, replacing any uses of dst with
// crit_mbb.
// Scan the operands of this branch, finding all uses of this MBB
std::vector<unsigned> toRemove;
unsigned reg = 0;
for (unsigned i = 0, e = mii->getNumOperands(); i != e; ++i) {
MachineOperand & mo = mii->getOperand(i);
if (mo.isMachineBasicBlock() &&
mo.getMachineBasicBlock() == dst) {
found_branch = true;
mo.setMachineBasicBlock(crit_mbb);
}
mo.getMachineBasicBlock() == dst)
reg = mii->getOperand(i-1).getReg();
toRemove.push_back(i-1);
}
// Remove all uses of this MBB
for (std::vector<unsigned>::reverse_iterator I = toRemove.rbegin(),
E = toRemove.rend(); I != E; ++I) {
mii->RemoveOperand(*I+1);
mii->RemoveOperand(*I);
}
// Add a single use corresponding to the new MBB
mii->addRegOperand(reg, false);
mii->addMachineBasicBlockOperand(crit_mbb);
}
// TODO: This is tentative. It may be necessary to fix this code. Maybe