When accessing the base register for global variables, use the register

directly rather than making a copy for the register allocator to coalesce.
This kills thousands of live intervals across the testsuite.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17946 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nate Begeman 2004-11-18 06:51:29 +00:00
parent c8b9f33ac0
commit 1f5308e5b5

View File

@ -417,12 +417,12 @@ namespace {
Value *Cond, Value *TrueVal, Value *FalseVal, Value *Cond, Value *TrueVal, Value *FalseVal,
unsigned DestReg); unsigned DestReg);
/// copyGlobalBaseToRegister - Output the instructions required to put the /// getGlobalBaseReg - Output the instructions required to put the
/// base address to use for accessing globals into a register. /// base address to use for accessing globals into a register. Returns the
/// register containing the base address.
/// ///
void copyGlobalBaseToRegister(MachineBasicBlock *MBB, unsigned getGlobalBaseReg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator IP, MachineBasicBlock::iterator IP);
unsigned R);
/// copyConstantToRegister - Output the instructions required to put the /// copyConstantToRegister - Output the instructions required to put the
/// specified constant into the specified register. /// specified constant into the specified register.
@ -587,12 +587,11 @@ unsigned PPC32ISel::getFixedSizedAllocaFI(AllocaInst *AI) {
} }
/// copyGlobalBaseToRegister - Output the instructions required to put the /// getGlobalBaseReg - Output the instructions required to put the
/// base address to use for accessing globals into a register. /// base address to use for accessing globals into a register.
/// ///
void PPC32ISel::copyGlobalBaseToRegister(MachineBasicBlock *MBB, unsigned PPC32ISel::getGlobalBaseReg(MachineBasicBlock *MBB,
MachineBasicBlock::iterator IP, MachineBasicBlock::iterator IP) {
unsigned R) {
if (!GlobalBaseInitialized) { if (!GlobalBaseInitialized) {
// Insert the set of GlobalBaseReg into the first MBB of the function // Insert the set of GlobalBaseReg into the first MBB of the function
MachineBasicBlock &FirstMBB = F->front(); MachineBasicBlock &FirstMBB = F->front();
@ -602,10 +601,7 @@ void PPC32ISel::copyGlobalBaseToRegister(MachineBasicBlock *MBB,
BuildMI(FirstMBB, MBBI, PPC::MFLR, 1, GlobalBaseReg).addReg(PPC::LR); BuildMI(FirstMBB, MBBI, PPC::MFLR, 1, GlobalBaseReg).addReg(PPC::LR);
GlobalBaseInitialized = true; GlobalBaseInitialized = true;
} }
// Emit our copy of GlobalBaseReg to the destination register in the return GlobalBaseReg;
// current MBB
BuildMI(*MBB, IP, PPC::OR, 2, R).addReg(GlobalBaseReg)
.addReg(GlobalBaseReg);
} }
/// copyConstantToRegister - Output the instructions required to put the /// copyConstantToRegister - Output the instructions required to put the
@ -691,9 +687,8 @@ void PPC32ISel::copyConstantToRegister(MachineBasicBlock *MBB,
unsigned Reg1 = makeAnotherReg(Type::IntTy); unsigned Reg1 = makeAnotherReg(Type::IntTy);
unsigned Opcode = (Ty == Type::FloatTy) ? PPC::LFS : PPC::LFD; unsigned Opcode = (Ty == Type::FloatTy) ? PPC::LFS : PPC::LFD;
// Move value at base + distance into return reg // Move value at base + distance into return reg
copyGlobalBaseToRegister(MBB, IP, GlobalBase); BuildMI(*MBB, IP, PPC::LOADHiAddr, 2, Reg1)
BuildMI(*MBB, IP, PPC::LOADHiAddr, 2, Reg1).addReg(GlobalBase) .addReg(getGlobalBaseReg(MBB, IP)).addConstantPoolIndex(CPI);
.addConstantPoolIndex(CPI);
BuildMI(*MBB, IP, Opcode, 2, R).addConstantPoolIndex(CPI).addReg(Reg1); BuildMI(*MBB, IP, Opcode, 2, R).addConstantPoolIndex(CPI).addReg(Reg1);
} else if (isa<ConstantPointerNull>(C)) { } else if (isa<ConstantPointerNull>(C)) {
// Copy zero (null pointer) to the register. // Copy zero (null pointer) to the register.
@ -708,9 +703,8 @@ void PPC32ISel::copyConstantToRegister(MachineBasicBlock *MBB,
|| dyn_cast<Function>(GV)) ? PPC::LWZ : PPC::LA; || dyn_cast<Function>(GV)) ? PPC::LWZ : PPC::LA;
// Move value at base + distance into return reg // Move value at base + distance into return reg
copyGlobalBaseToRegister(MBB, IP, GlobalBase); BuildMI(*MBB, IP, PPC::LOADHiAddr, 2, TmpReg)
BuildMI(*MBB, IP, PPC::LOADHiAddr, 2, TmpReg).addReg(GlobalBase) .addReg(getGlobalBaseReg(MBB, IP)).addGlobalAddress(GV);
.addGlobalAddress(GV);
BuildMI(*MBB, IP, Opcode, 2, R).addGlobalAddress(GV).addReg(TmpReg); BuildMI(*MBB, IP, Opcode, 2, R).addGlobalAddress(GV).addReg(TmpReg);
// Add the GV to the list of things whose addresses have been taken. // Add the GV to the list of things whose addresses have been taken.