aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Mips/MipsFrameLowering.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2012-07-11 00:53:32 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2012-07-11 00:53:32 +0000
commit878ad8b28d1f69614b05a1469fa6955d46ac699e (patch)
tree135d0eeb716fabcd68d4b08bcb94e3d728a624bf /llvm/lib/Target/Mips/MipsFrameLowering.cpp
parent8889cf008d850f22d60f74f502486dc239ab6903 (diff)
downloadllvm-878ad8b28d1f69614b05a1469fa6955d46ac699e.zip
llvm-878ad8b28d1f69614b05a1469fa6955d46ac699e.tar.gz
llvm-878ad8b28d1f69614b05a1469fa6955d46ac699e.tar.bz2
Lower RETURNADDR node in Mips backend.
Patch by Sasa Stankovic. llvm-svn: 160031
Diffstat (limited to 'llvm/lib/Target/Mips/MipsFrameLowering.cpp')
-rw-r--r--llvm/lib/Target/Mips/MipsFrameLowering.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/Target/Mips/MipsFrameLowering.cpp b/llvm/lib/Target/Mips/MipsFrameLowering.cpp
index 95e2357..cb55995 100644
--- a/llvm/lib/Target/Mips/MipsFrameLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsFrameLowering.cpp
@@ -273,14 +273,21 @@ spillCalleeSavedRegisters(MachineBasicBlock &MBB,
const TargetInstrInfo &TII = *MF->getTarget().getInstrInfo();
for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
- // Add the callee-saved register as live-in.
- // It's killed at the spill.
- EntryBlock->addLiveIn(CSI[i].getReg());
+ // Add the callee-saved register as live-in. Do not add if the register is
+ // RA and return address is taken, because it has already been added in
+ // method MipsTargetLowering::LowerRETURNADDR.
+ // It's killed at the spill, unless the register is RA and return address
+ // is taken.
+ unsigned Reg = CSI[i].getReg();
+ bool IsRAAndRetAddrIsTaken = (Reg == Mips::RA || Reg == Mips::RA_64)
+ && MF->getFrameInfo()->isReturnAddressTaken();
+ if (!IsRAAndRetAddrIsTaken)
+ EntryBlock->addLiveIn(Reg);
// Insert the spill to the stack frame.
- unsigned Reg = CSI[i].getReg();
+ bool IsKill = !IsRAAndRetAddrIsTaken;
const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
- TII.storeRegToStackSlot(*EntryBlock, MI, Reg, true,
+ TII.storeRegToStackSlot(*EntryBlock, MI, Reg, IsKill,
CSI[i].getFrameIdx(), RC, TRI);
}