[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocSimple.cpp
Misha Brukman
brukman at cs.uiuc.edu
Fri Dec 13 05:57:01 PST 2002
Changes in directory llvm/lib/CodeGen:
RegAllocSimple.cpp updated: 1.10 -> 1.11
---
Log message:
Need to insert all moves due to PHI nodes before *ALL* jumps in a predecessor
basic block, as there could be multiple.
---
Diffs of the changes:
Index: llvm/lib/CodeGen/RegAllocSimple.cpp
diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.10 llvm/lib/CodeGen/RegAllocSimple.cpp:1.11
--- llvm/lib/CodeGen/RegAllocSimple.cpp:1.10 Fri Dec 13 05:33:22 2002
+++ llvm/lib/CodeGen/RegAllocSimple.cpp Fri Dec 13 05:55:59 2002
@@ -92,21 +92,6 @@
regs = Desc.ImplicitDefs;
while (*regs)
RegsUsed[*regs++] = 1;
-
-
- /*
- for (int i = MI->getNumOperands() - 1; i >= 0; --i) {
- const MachineOperand &op = MI->getOperand(i);
- if (op.isMachineRegister())
- RegsUsed[op.getAllocatedRegNum()] = 1;
- }
-
- for (int i = MI->getNumImplicitRefs() - 1; i >= 0; --i) {
- const MachineOperand &op = MI->getImplicitOp(i);
- if (op.isMachineRegister())
- RegsUsed[op.getAllocatedRegNum()] = 1;
- }
- */
}
void cleanupAfterFunction() {
@@ -297,6 +282,16 @@
MachineBasicBlock::iterator opI = opBlock->end();
MachineInstr *opMI = *(--opI);
const MachineInstrInfo &MII = TM.getInstrInfo();
+ // must backtrack over ALL the branches in the previous block, until no more
+ while ((MII.isBranch(opMI->getOpcode()) || MII.isReturn(opMI->getOpcode()))
+ && opI != opBlock->begin())
+ {
+ opMI = *(--opI);
+ }
+ // move back to the first branch instruction so new instructions
+ // are inserted right in front of it and not in front of a non-branch
+ ++opI;
+
// insert the move just before the return/branch
if (MII.isReturn(opMI->getOpcode()) || MII.isBranch(opMI->getOpcode()))
More information about the llvm-commits
mailing list