llvm.org GIT mirror llvm / e6e1384
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 Owen Anderson 12 years ago
1 changed file(s) with 17 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
5151 break;
5252 }
5353
54 // Scan the operands of this branch, replacing any uses of dst with
55 // crit_mbb.
54 // Scan the operands of this branch, finding all uses of this MBB
55 std::vector toRemove;
56 unsigned reg = 0;
5657 for (unsigned i = 0, e = mii->getNumOperands(); i != e; ++i) {
5758 MachineOperand & mo = mii->getOperand(i);
5859 if (mo.isMachineBasicBlock() &&
59 mo.getMachineBasicBlock() == dst) {
60 found_branch = true;
61 mo.setMachineBasicBlock(crit_mbb);
62 }
60 mo.getMachineBasicBlock() == dst)
61 reg = mii->getOperand(i-1).getReg();
62 toRemove.push_back(i-1);
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);
6475 }
6576
6677 // TODO: This is tentative. It may be necessary to fix this code. Maybe