diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-07-08 16:49:26 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-07-08 16:49:26 +0000 |
commit | ed903d746d96d071305b8182680595ba281b3f12 (patch) | |
tree | f0c6e5950bc015164ae4160b037050af13a89ddb /lib/CodeGen/RegisterScavenging.cpp | |
parent | 0bc25f40402f48ba42fc45403f635b20d90fabb3 (diff) | |
download | llvm-ed903d746d96d071305b8182680595ba281b3f12.tar.gz llvm-ed903d746d96d071305b8182680595ba281b3f12.tar.bz2 llvm-ed903d746d96d071305b8182680595ba281b3f12.tar.xz |
Clean up scavengeRegister() a bit to prefer available regs, which allows
the simplification of frame index register scavenging to not have to check
for available registers directly and instead just let scavengeRegister()
handle it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107880 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegisterScavenging.cpp')
-rw-r--r-- | lib/CodeGen/RegisterScavenging.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/CodeGen/RegisterScavenging.cpp b/lib/CodeGen/RegisterScavenging.cpp index 8a1ef5adf7..43b3fb6426 100644 --- a/lib/CodeGen/RegisterScavenging.cpp +++ b/lib/CodeGen/RegisterScavenging.cpp @@ -339,13 +339,16 @@ unsigned RegScavenger::scavengeRegister(const TargetRegisterClass *RC, Candidates.reset(MO.getReg()); } + // 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; + // Find the register whose use is furthest away. MachineBasicBlock::iterator UseMI; unsigned SReg = findSurvivorReg(I, Candidates, 25, UseMI); - // If we found an unused register there is no reason to spill it. We have - // probably found a callee-saved register that has been saved in the - // prologue, but happens to be unused at this point. + // If we found an unused register there is no reason to spill it. if (!isAliasUsed(SReg)) return SReg; |