From 76f1b47ec9ff0c91a48b86329d77596d81717546 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 17 Mar 2009 01:23:09 +0000 Subject: Spiller may unfold load / mod / store instructions as an optimization when the would be loaded value is available in a register. It needs to check if it's legal to clobber the register. Also, the register can contain values of multiple spill slots, make sure to check all instead of just the one being unfolded. llvm-svn: 67068 --- llvm/lib/CodeGen/Spiller.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'llvm/lib/CodeGen/Spiller.h') diff --git a/llvm/lib/CodeGen/Spiller.h b/llvm/lib/CodeGen/Spiller.h index e85922ec397..5a42a8279db 100644 --- a/llvm/lib/CodeGen/Spiller.h +++ b/llvm/lib/CodeGen/Spiller.h @@ -127,15 +127,31 @@ namespace llvm { DOUT << " in physreg " << TRI->getName(Reg) << "\n"; } - /// canClobberPhysReg - Return true if the spiller is allowed to change the - /// value of the specified stackslot register if it desires. The specified - /// stack slot must be available in a physreg for this query to make sense. - bool canClobberPhysReg(int SlotOrReMat) const { + /// canClobberPhysRegForSS - Return true if the spiller is allowed to change + /// the value of the specified stackslot register if it desires. The + /// specified stack slot must be available in a physreg for this query to + /// make sense. + bool canClobberPhysRegForSS(int SlotOrReMat) const { assert(SpillSlotsOrReMatsAvailable.count(SlotOrReMat) && "Value not available!"); return SpillSlotsOrReMatsAvailable.find(SlotOrReMat)->second & 1; } + /// canClobberPhysReg - Return true if the spiller is allowed to clobber the + /// physical register where values for some stack slot(s) might be + /// available. + bool canClobberPhysReg(unsigned PhysReg) const { + std::multimap::const_iterator I = + PhysRegsAvailable.lower_bound(PhysReg); + while (I != PhysRegsAvailable.end() && I->first == PhysReg) { + int SlotOrReMat = I->second; + I++; + if (!canClobberPhysRegForSS(SlotOrReMat)) + return false; + } + return true; + } + /// disallowClobberPhysReg - Unset the CanClobber bit of the specified /// stackslot register. The register is still available but is no longer /// allowed to be modifed. @@ -305,4 +321,4 @@ namespace llvm { }; } -#endif \ No newline at end of file +#endif -- cgit v1.2.3