summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/RegAllocSimple.cpp
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2002-12-13 11:55:59 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2002-12-13 11:55:59 +0000
commit86ca8840a1886b26a09aa561ade19335e9aa8bbf (patch)
tree5fcfd4f8a8630e930ea9edf49d3dba90d1cbe3a0 /llvm/lib/CodeGen/RegAllocSimple.cpp
parentd4c5013c04dcfcd7f46899c629e4066979927cb0 (diff)
downloadbcm5719-llvm-86ca8840a1886b26a09aa561ade19335e9aa8bbf.tar.gz
bcm5719-llvm-86ca8840a1886b26a09aa561ade19335e9aa8bbf.zip
Need to insert all moves due to PHI nodes before *ALL* jumps in a predecessor
basic block, as there could be multiple. llvm-svn: 5016
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocSimple.cpp')
-rw-r--r--llvm/lib/CodeGen/RegAllocSimple.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/llvm/lib/CodeGen/RegAllocSimple.cpp b/llvm/lib/CodeGen/RegAllocSimple.cpp
index 3a58b5abeed..6def3a178ad 100644
--- a/llvm/lib/CodeGen/RegAllocSimple.cpp
+++ b/llvm/lib/CodeGen/RegAllocSimple.cpp
@@ -92,21 +92,6 @@ namespace {
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 @@ bool RegAllocSimple::runOnMachineFunction(MachineFunction &Fn) {
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()))
OpenPOWER on IntegriCloud