[llvm-commits] [llvm] r44061 - /llvm/trunk/include/llvm/CodeGen/BreakCriticalMachineEdge.h
Owen Anderson
resistor at mac.com
Tue Nov 13 11:56:28 PST 2007
Author: resistor
Date: Tue Nov 13 13:56:28 2007
New Revision: 44061
URL: http://llvm.org/viewvc/llvm-project?rev=44061&view=rev
Log:
Wow. I definitely shouldn't write code when I'm tird.
Make my previous patch actually do what it was intended to do.
Modified:
llvm/trunk/include/llvm/CodeGen/BreakCriticalMachineEdge.h
Modified: llvm/trunk/include/llvm/CodeGen/BreakCriticalMachineEdge.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/BreakCriticalMachineEdge.h?rev=44061&r1=44060&r2=44061&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/BreakCriticalMachineEdge.h (original)
+++ llvm/trunk/include/llvm/CodeGen/BreakCriticalMachineEdge.h Tue Nov 13 13:56:28 2007
@@ -52,27 +52,16 @@
break;
}
- // Scan the operands of this branch, finding all uses of this MBB
- std::vector<unsigned> toRemove;
- unsigned reg = 0;
+ // Scan the operands of this branch, replacing any uses of dst with
+ // crit_mbb.
for (unsigned i = 0, e = mii->getNumOperands(); i != e; ++i) {
MachineOperand & mo = mii->getOperand(i);
if (mo.isMachineBasicBlock() &&
- mo.getMachineBasicBlock() == dst)
- reg = mii->getOperand(i-1).getReg();
- toRemove.push_back(i-1);
+ mo.getMachineBasicBlock() == dst) {
+ found_branch = true;
+ mo.setMachineBasicBlock(crit_mbb);
+ }
}
-
- // 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
@@ -89,10 +78,26 @@
if(mii->getOpcode() != TargetInstrInfo::PHI)
break;
+ // Find the operands corresponding to the source block
+ std::vector<unsigned> toRemove;
+ unsigned reg = 0;
for (unsigned u = 0; u != mii->getNumOperands(); ++u)
if (mii->getOperand(u).isMachineBasicBlock() &&
- mii->getOperand(u).getMachineBasicBlock() == src)
- mii->getOperand(u).setMachineBasicBlock(crit_mbb);
+ mii->getOperand(u).getMachineBasicBlock() == src) {
+ reg = mii->getOperand(u-1).getReg();
+ toRemove.push_back(u-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);
}
return crit_mbb;
More information about the llvm-commits
mailing list