llvm.org GIT mirror llvm / 660c5b9
Wow. I definitely shouldn't write code when I'm tird. Make my previous patch actually do what it was intended to do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44061 91177308-0d34-0410-b5e6-96231b3b80d8 Owen Anderson 12 years ago
1 changed file(s) with 24 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
5151 break;
5252 }
5353
54 // Scan the operands of this branch, finding all uses of this MBB
55 std::vector toRemove;
56 unsigned reg = 0;
54 // Scan the operands of this branch, replacing any uses of dst with
55 // crit_mbb.
5756 for (unsigned i = 0, e = mii->getNumOperands(); i != e; ++i) {
5857 MachineOperand & mo = mii->getOperand(i);
5958 if (mo.isMachineBasicBlock() &&
60 mo.getMachineBasicBlock() == dst)
61 reg = mii->getOperand(i-1).getReg();
62 toRemove.push_back(i-1);
59 mo.getMachineBasicBlock() == dst) {
60 found_branch = true;
61 mo.setMachineBasicBlock(crit_mbb);
62 }
6363 }
64
65 // Remove all uses of this MBB
66 for (std::vector::reverse_iterator I = toRemove.rbegin(),
67 E = toRemove.rend(); I != E; ++I) {
68 mii->RemoveOperand(*I+1);
69 mii->RemoveOperand(*I);
70 }
71
72 // Add a single use corresponding to the new MBB
73 mii->addRegOperand(reg, false);
74 mii->addMachineBasicBlockOperand(crit_mbb);
7564 }
7665
7766 // TODO: This is tentative. It may be necessary to fix this code. Maybe
8877 if(mii->getOpcode() != TargetInstrInfo::PHI)
8978 break;
9079
80 // Find the operands corresponding to the source block
81 std::vector toRemove;
82 unsigned reg = 0;
9183 for (unsigned u = 0; u != mii->getNumOperands(); ++u)
9284 if (mii->getOperand(u).isMachineBasicBlock() &&
93 mii->getOperand(u).getMachineBasicBlock() == src)
94 mii->getOperand(u).setMachineBasicBlock(crit_mbb);
85 mii->getOperand(u).getMachineBasicBlock() == src) {
86 reg = mii->getOperand(u-1).getReg();
87 toRemove.push_back(u-1);
88 }
89
90 // Remove all uses of this MBB
91 for (std::vector::reverse_iterator I = toRemove.rbegin(),
92 E = toRemove.rend(); I != E; ++I) {
93 mii->RemoveOperand(*I+1);
94 mii->RemoveOperand(*I);
95 }
96
97 // Add a single use corresponding to the new MBB
98 mii->addRegOperand(reg, false);
99 mii->addMachineBasicBlockOperand(crit_mbb);
95100 }
96101
97102 return crit_mbb;