diff options
author | Jim Grosbach <grosbach@apple.com> | 2011-03-05 00:20:19 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2011-03-05 00:20:19 +0000 |
commit | 27ea9999e84dfb1e6c2baf06ec27a92f12753917 (patch) | |
tree | 6c0bff33f62a3b2ca5fc5de5e1c4b227bcbd1e99 /lib/CodeGen | |
parent | 515c67ee77f8d9c417efc0fe04615d269bfb70e4 (diff) | |
download | external_llvm-27ea9999e84dfb1e6c2baf06ec27a92f12753917.zip external_llvm-27ea9999e84dfb1e6c2baf06ec27a92f12753917.tar.gz external_llvm-27ea9999e84dfb1e6c2baf06ec27a92f12753917.tar.bz2 |
Teach the register scavenger to take subregs into account when finding a free register.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127049 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/RegisterScavenging.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/CodeGen/RegisterScavenging.cpp b/lib/CodeGen/RegisterScavenging.cpp index a2580b8..b9dd28e 100644 --- a/lib/CodeGen/RegisterScavenging.cpp +++ b/lib/CodeGen/RegisterScavenging.cpp @@ -241,12 +241,13 @@ unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RC) const { /// getRegsAvailable - Return all available registers in the register class /// in Mask. -void RegScavenger::getRegsAvailable(const TargetRegisterClass *RC, - BitVector &Mask) { +BitVector RegScavenger::getRegsAvailable(const TargetRegisterClass *RC) { + BitVector Mask(TRI->getNumRegs()); for (TargetRegisterClass::iterator I = RC->begin(), E = RC->end(); I != E; ++I) if (!isAliasUsed(*I)) Mask.set(*I); + return Mask; } /// findSurvivorReg - Return the candidate register that is unused for the @@ -335,9 +336,13 @@ unsigned RegScavenger::scavengeRegister(const TargetRegisterClass *RC, } // Try to find a register that's unused if there is one, as then we won't - // have to spill. - if ((Candidates & RegsAvailable).any()) - Candidates &= RegsAvailable; + // have to spill. Search explicitly rather than masking out based on + // RegsAvailable, as RegsAvailable does not take aliases into account. + // That's what getRegsAvailable() is for. + BitVector Available = getRegsAvailable(RC); + + if ((Candidates & Available).any()) + Candidates &= Available; // Find the register whose use is furthest away. MachineBasicBlock::iterator UseMI; |