diff options
| author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-05-11 20:30:28 +0000 |
|---|---|---|
| committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-05-11 20:30:28 +0000 |
| commit | 3f0241e0f9646cd5b1f474056236d9a2b68d2c76 (patch) | |
| tree | 4443808e487a112b54c77e2d1f93dfb5f715a131 /llvm/lib | |
| parent | e7630be7c54c5197ba1fa6b609ff9cd1c31d01ff (diff) | |
| download | bcm5719-llvm-3f0241e0f9646cd5b1f474056236d9a2b68d2c76.tar.gz bcm5719-llvm-3f0241e0f9646cd5b1f474056236d9a2b68d2c76.zip | |
Simplify the tracking of used physregs to a bulk bitor followed by a transitive
closure after allocating all blocks.
Add a few more test cases for -regalloc=fast.
llvm-svn: 103500
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/CodeGen/MachineRegisterInfo.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/RegAllocFast.cpp | 13 |
2 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineRegisterInfo.cpp b/llvm/lib/CodeGen/MachineRegisterInfo.cpp index ef794d5ae3c..4a150435cef 100644 --- a/llvm/lib/CodeGen/MachineRegisterInfo.cpp +++ b/llvm/lib/CodeGen/MachineRegisterInfo.cpp @@ -267,6 +267,15 @@ MachineRegisterInfo::EmitLiveInCopies(MachineBasicBlock *EntryMBB, EntryMBB->addLiveIn(I->first); } +void MachineRegisterInfo::closePhysRegsUsed(const TargetRegisterInfo &TRI) { + for (int i = UsedPhysRegs.find_first(); i >= 0; + i = UsedPhysRegs.find_next(i)) + for (const unsigned *SS = TRI.getSubRegisters(i); + unsigned SubReg = *SS; ++SS) + if (SubReg > i) + UsedPhysRegs.set(SubReg); +} + #ifndef NDEBUG void MachineRegisterInfo::dumpUses(unsigned Reg) const { for (use_iterator I = use_begin(Reg), E = use_end(); I != E; ++I) diff --git a/llvm/lib/CodeGen/RegAllocFast.cpp b/llvm/lib/CodeGen/RegAllocFast.cpp index 488f630aa61..6bc492ed38c 100644 --- a/llvm/lib/CodeGen/RegAllocFast.cpp +++ b/llvm/lib/CodeGen/RegAllocFast.cpp @@ -370,11 +370,9 @@ unsigned RAFast::allocVirtReg(MachineBasicBlock &MBB, MachineInstr *MI, if (PhysRegState[BestReg] != regDisabled) spillVirtReg(MBB, MI, PhysRegState[BestReg], true); else { - MF->getRegInfo().setPhysRegUsed(BestReg); // Make sure all aliases are disabled. for (const unsigned *AS = TRI->getAliasSet(BestReg); unsigned Alias = *AS; ++AS) { - MF->getRegInfo().setPhysRegUsed(Alias); switch (PhysRegState[Alias]) { case regDisabled: continue; @@ -443,6 +441,7 @@ unsigned RAFast::reloadVirtReg(MachineBasicBlock &MBB, MachineInstr *MI, /// defineVirtReg except the physreg is reverved instead of allocated. void RAFast::reservePhysReg(MachineBasicBlock &MBB, MachineInstr *MI, unsigned PhysReg) { + UsedInInstr.set(PhysReg); switch (unsigned VirtReg = PhysRegState[PhysReg]) { case regDisabled: break; @@ -460,6 +459,7 @@ void RAFast::reservePhysReg(MachineBasicBlock &MBB, MachineInstr *MI, // This is a disabled register, disable all aliases. for (const unsigned *AS = TRI->getAliasSet(PhysReg); unsigned Alias = *AS; ++AS) { + UsedInInstr.set(Alias); switch (unsigned VirtReg = PhysRegState[Alias]) { case regDisabled: case regFree: @@ -474,10 +474,8 @@ void RAFast::reservePhysReg(MachineBasicBlock &MBB, MachineInstr *MI, break; } PhysRegState[Alias] = regDisabled; - MF->getRegInfo().setPhysRegUsed(Alias); } PhysRegState[PhysReg] = regReserved; - MF->getRegInfo().setPhysRegUsed(PhysReg); } // setPhysReg - Change MO the refer the PhysReg, considering subregs. @@ -611,6 +609,8 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) { killPhysReg(PhysKills[i]); PhysKills.clear(); + MF->getRegInfo().addPhysRegsUsed(UsedInInstr); + // Track registers defined by instruction - early clobbers at this point. UsedInInstr.reset(); for (unsigned i = 0, e = PhysDefs.size(); i != e; ++i) { @@ -658,6 +658,8 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) { for (unsigned i = 0, e = PhysKills.size(); i != e; ++i) killPhysReg(PhysKills[i]); PhysKills.clear(); + + MF->getRegInfo().addPhysRegsUsed(UsedInInstr); } // Spill all physical registers holding virtual registers now. @@ -693,6 +695,9 @@ bool RAFast::runOnMachineFunction(MachineFunction &Fn) { MBB != MBBe; ++MBB) AllocateBasicBlock(*MBB); + // Make sure the set of used physregs is closed under subreg operations. + MF->getRegInfo().closePhysRegsUsed(*TRI); + StackSlotForVirtReg.clear(); return true; } |

