[llvm-commits] [llvm] r107880 - in /llvm/trunk/lib/CodeGen: PrologEpilogInserter.cpp RegisterScavenging.cpp
Jim Grosbach
grosbach at apple.com
Thu Jul 8 09:49:27 PDT 2010
Author: grosbach
Date: Thu Jul 8 11:49:26 2010
New Revision: 107880
URL: http://llvm.org/viewvc/llvm-project?rev=107880&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
llvm/trunk/lib/CodeGen/RegisterScavenging.cpp
Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=107880&r1=107879&r2=107880&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
+++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Thu Jul 8 11:49:26 2010
@@ -885,21 +885,7 @@
// Scavenge a new scratch register
CurrentVirtReg = Reg;
const TargetRegisterClass *RC = Fn.getRegInfo().getRegClass(Reg);
- const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo();
- BitVector Candidates(TRI->getNumRegs());
- RS->getRegsAvailable(RC, Candidates);
-
- // If there are any registers available, use the one that's
- // unused for the longest after this instruction. That increases
- // the ability to reuse the value.
- if (Candidates.any()) {
- MachineBasicBlock::iterator UMI;
- CurrentScratchReg = RS->findSurvivorReg(I, Candidates, 25, UMI);
- } else {
- // No register is "free". Scavenge a register.
- CurrentScratchReg = RS->scavengeRegister(RC, I, SPAdj);
- }
-
+ CurrentScratchReg = RS->scavengeRegister(RC, I, SPAdj);
PrevValue = Value;
}
// replace this reference to the virtual register with the
Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=107880&r1=107879&r2=107880&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Thu Jul 8 11:49:26 2010
@@ -339,13 +339,16 @@
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;
More information about the llvm-commits
mailing list