summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/RegAllocSimple.cpp
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2002-12-13 12:33:31 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2002-12-13 12:33:31 +0000
commita1aa29b12554af508660890bfed2d0f650776cb7 (patch)
treeca8e99d8b079f8725b9fb2fb789d04546e3909fc /llvm/lib/CodeGen/RegAllocSimple.cpp
parent371a8788631846e34d5e4404f279d32f3374f5b3 (diff)
downloadbcm5719-llvm-a1aa29b12554af508660890bfed2d0f650776cb7.tar.gz
bcm5719-llvm-a1aa29b12554af508660890bfed2d0f650776cb7.zip
Fixed a bug where moves due to phis were being neglected.
llvm-svn: 5019
Diffstat (limited to 'llvm/lib/CodeGen/RegAllocSimple.cpp')
-rw-r--r--llvm/lib/CodeGen/RegAllocSimple.cpp42
1 files changed, 19 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/RegAllocSimple.cpp b/llvm/lib/CodeGen/RegAllocSimple.cpp
index 6def3a178ad..cbe131c81d0 100644
--- a/llvm/lib/CodeGen/RegAllocSimple.cpp
+++ b/llvm/lib/CodeGen/RegAllocSimple.cpp
@@ -253,7 +253,7 @@ bool RegAllocSimple::runOnMachineFunction(MachineFunction &Fn) {
if (targetReg.isVirtualRegister()) {
physReg = getFreeReg(virtualReg);
} else {
- physReg = targetReg.getAllocatedRegNum();
+ physReg = virtualReg;
}
// Find the register class of the target register: should be the
@@ -293,29 +293,25 @@ bool RegAllocSimple::runOnMachineFunction(MachineFunction &Fn) {
++opI;
- // insert the move just before the return/branch
- if (MII.isReturn(opMI->getOpcode()) || MII.isBranch(opMI->getOpcode()))
+ // Retrieve the constant value from this op, move it to target
+ // register of the phi
+ if (opVal.getType() == MachineOperand::MO_SignExtendedImmed ||
+ opVal.getType() == MachineOperand::MO_UnextendedImmed)
{
- // Retrieve the constant value from this op, move it to target
- // register of the phi
- if (opVal.getType() == MachineOperand::MO_SignExtendedImmed ||
- opVal.getType() == MachineOperand::MO_UnextendedImmed)
- {
- opI = RegInfo->moveImm2Reg(opBlock, opI, physReg,
- (unsigned) opVal.getImmedValue(),
- dataSize);
- saveVirtRegToStack(opBlock, opI, virtualReg, physReg);
- } else {
- // Allocate a physical register and add a move in the BB
- unsigned opVirtualReg = (unsigned) opVal.getAllocatedRegNum();
- unsigned opPhysReg; // = getFreeReg(opVirtualReg);
- opI = moveUseToReg(opBlock, opI, opVirtualReg, opPhysReg);
- opI = RegInfo->moveReg2Reg(opBlock, opI, physReg, opPhysReg,
- dataSize);
- // Save that register value to the stack of the TARGET REG
- saveVirtRegToStack(opBlock, opI, virtualReg, opPhysReg);
- }
- }
+ opI = RegInfo->moveImm2Reg(opBlock, opI, physReg,
+ (unsigned) opVal.getImmedValue(),
+ dataSize);
+ saveVirtRegToStack(opBlock, opI, virtualReg, physReg);
+ } else {
+ // Allocate a physical register and add a move in the BB
+ unsigned opVirtualReg = (unsigned) opVal.getAllocatedRegNum();
+ unsigned opPhysReg; // = getFreeReg(opVirtualReg);
+ opI = moveUseToReg(opBlock, opI, opVirtualReg, physReg);
+ //opI = RegInfo->moveReg2Reg(opBlock, opI, physReg, opPhysReg,
+ // dataSize);
+ // Save that register value to the stack of the TARGET REG
+ saveVirtRegToStack(opBlock, opI, virtualReg, physReg);
+ }
// make regs available to other instructions
clearAllRegs();
OpenPOWER on IntegriCloud