diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2007-03-07 20:30:36 +0000 | 
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2007-03-07 20:30:36 +0000 | 
| commit | f030f2d628412f58659271f46c36e5e90fdab4d4 (patch) | |
| tree | 9a4f99a56ba19380a5acdb17d551f90bd5752525 /llvm/lib | |
| parent | 6d8211c0ac87a8c55a8c7974b2e3940fd2b8abfd (diff) | |
| download | bcm5719-llvm-f030f2d628412f58659271f46c36e5e90fdab4d4.tar.gz bcm5719-llvm-f030f2d628412f58659271f46c36e5e90fdab4d4.zip | |
Only safe to use a call-clobbered or spilled callee-saved register as scratch register.
llvm-svn: 35010
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp | 10 | 
1 files changed, 8 insertions, 2 deletions
| diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp index 59421b9ca8b..ab86bbf9b79 100644 --- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp +++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp @@ -15,6 +15,7 @@  #define DEBUG_TYPE "arm-ldst-opt"  #include "ARM.h"  #include "ARMAddressingModes.h" +#include "ARMMachineFunctionInfo.h"  #include "ARMRegisterInfo.h"  #include "llvm/ADT/STLExtras.h"  #include "llvm/ADT/SmallVector.h" @@ -39,6 +40,7 @@ namespace {    struct VISIBILITY_HIDDEN ARMLoadStoreOpt : public MachineFunctionPass {      const TargetInstrInfo *TII;      const MRegisterInfo *MRI; +    ARMFunctionInfo *AFI;      RegScavenger *RS;      MachineBasicBlock::iterator RSI; @@ -587,8 +589,11 @@ bool ARMLoadStoreOpt::LoadStoreMultipleOpti(MachineBasicBlock &MBB) {          // First advance to the instruction just before the start of the chain.          if (RSI != MBB.begin())            RS->forward(prior(RSI)); -        // Find a scratch register. -        Scratch = RS->FindUnusedReg(&ARM::GPRRegClass); +        // Find a scratch register. Make sure it's a call clobbered register or +        // a spilled callee-saved register. +        Scratch = RS->FindUnusedReg(&ARM::GPRRegClass, true); +        if (!Scratch) +          RS->FindUnusedReg(&ARM::GPRRegClass, AFI->getSpilledCSRegisters());          // Process the load / store instructions.          RS->forward(prior(MBBI)); @@ -661,6 +666,7 @@ bool ARMLoadStoreOpt::MergeReturnIntoLDM(MachineBasicBlock &MBB) {  bool ARMLoadStoreOpt::runOnMachineFunction(MachineFunction &Fn) {    const TargetMachine &TM = Fn.getTarget(); +  AFI = Fn.getInfo<ARMFunctionInfo>();    TII = TM.getInstrInfo();    MRI = TM.getRegisterInfo();    RS = new RegScavenger(); | 

