From 62871a34609d669a3825936993e490f7e5053628 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Wed, 27 Jun 2012 00:20:39 +0000 Subject: [PATCH] Fix bug in computation of stack size in MipsFrameLowering.cpp. llvm-svn: 159240 --- llvm/lib/Target/Mips/MipsFrameLowering.cpp | 9 ++++++--- llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/Mips/MipsFrameLowering.cpp b/llvm/lib/Target/Mips/MipsFrameLowering.cpp index 15ab1c30cecb..5afd2fc576da 100644 --- a/llvm/lib/Target/Mips/MipsFrameLowering.cpp +++ b/llvm/lib/Target/Mips/MipsFrameLowering.cpp @@ -112,9 +112,12 @@ void MipsFrameLowering::emitPrologue(MachineFunction &MF) const { // First, compute final stack size. unsigned StackAlign = getStackAlignment(); - uint64_t StackSize = STI.inMips16Mode()? 0: - MFI->getObjectOffset(MipsFI->getGlobalRegFI()) + - StackAlign + RoundUpToAlignment(MFI->getStackSize(), StackAlign); + uint64_t StackSize = RoundUpToAlignment(MFI->getStackSize(), StackAlign); + + if (MipsFI->globalBaseRegSet()) + StackSize += MFI->getObjectOffset(MipsFI->getGlobalRegFI()) + StackAlign; + else + StackSize += RoundUpToAlignment(MipsFI->getMaxCallFrameSize(), StackAlign); // Update stack size MFI->setStackSize(StackSize); diff --git a/llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp b/llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp index 15e745f7ea1a..9f1c0f6d2f38 100644 --- a/llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp +++ b/llvm/lib/Target/Mips/MipsISelDAGToDAG.cpp @@ -117,6 +117,10 @@ private: void MipsDAGToDAGISel::InitGlobalBaseReg(MachineFunction &MF) { MipsFunctionInfo *MipsFI = MF.getInfo(); + if (((MF.getTarget().getRelocationModel() == Reloc::Static) || + Subtarget.inMips16Mode()) && !MipsFI->globalBaseRegSet()) + return; + MachineBasicBlock &MBB = MF.front(); MachineBasicBlock::iterator I = MBB.begin(); MachineRegisterInfo &RegInfo = MF.getRegInfo();