aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/Mips/MipsRegisterInfo.cpp
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanak@gmail.com>2011-07-01 01:04:43 +0000
committerAkira Hatanaka <ahatanak@gmail.com>2011-07-01 01:04:43 +0000
commitc4f24eb584f6b4dba3caba2ed766c7c4bf1bf8af (patch)
tree026b0f8b76975dcd8eb398566db1aa58a674b2c5 /lib/Target/Mips/MipsRegisterInfo.cpp
parent68c0dbc14fb7599987fb3e27be4e12c1ac36535e (diff)
downloadexternal_llvm-c4f24eb584f6b4dba3caba2ed766c7c4bf1bf8af.zip
external_llvm-c4f24eb584f6b4dba3caba2ed766c7c4bf1bf8af.tar.gz
external_llvm-c4f24eb584f6b4dba3caba2ed766c7c4bf1bf8af.tar.bz2
Improve Mips back-end's handling of DBG_VALUE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/Mips/MipsRegisterInfo.cpp')
-rw-r--r--lib/Target/Mips/MipsRegisterInfo.cpp53
1 files changed, 31 insertions, 22 deletions
diff --git a/lib/Target/Mips/MipsRegisterInfo.cpp b/lib/Target/Mips/MipsRegisterInfo.cpp
index 40774c9..202a1d4 100644
--- a/lib/Target/Mips/MipsRegisterInfo.cpp
+++ b/lib/Target/Mips/MipsRegisterInfo.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Analysis/DebugInfo.h"
#define GET_REGINFO_MC_DESC
#define GET_REGINFO_TARGET_DESC
@@ -179,8 +180,29 @@ eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
<< "spOffset : " << spOffset << "\n"
<< "stackSize : " << stackSize << "\n");
- int Offset;
+ const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
+ int MinCSFI = 0;
+ int MaxCSFI = -1;
+
+ if (CSI.size()) {
+ MinCSFI = CSI[0].getFrameIdx();
+ MaxCSFI = CSI[CSI.size() - 1].getFrameIdx();
+ }
+
+ // The following stack frame objects are always referenced relative to $sp:
+ // 1. Outgoing arguments.
+ // 2. Pointer to dynamically allocated stack space.
+ // 3. Locations for callee-saved registers.
+ // Everything else is referenced relative to whatever register
+ // getFrameRegister() returns.
+ unsigned FrameReg;
+ if (MipsFI->isOutArgFI(FrameIndex) || MipsFI->isDynAllocFI(FrameIndex) ||
+ (FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI))
+ FrameReg = Mips::SP;
+ else
+ FrameReg = getFrameRegister(MF);
+
// Calculate final offset.
// - There is no need to change the offset if the frame object is one of the
// following: an outgoing argument, pointer to a dynamically allocated
@@ -188,12 +210,20 @@ eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
// - If the frame object is any of the following, its offset must be adjusted
// by adding the size of the stack:
// incoming argument, callee-saved register location or local variable.
+ int Offset;
+
if (MipsFI->isOutArgFI(FrameIndex) || MipsFI->isGPFI(FrameIndex) ||
MipsFI->isDynAllocFI(FrameIndex))
Offset = spOffset;
else
Offset = spOffset + stackSize;
+ if (MI.isDebugValue()) {
+ MI.getOperand(i).ChangeToRegister(FrameReg, false /*isDef*/);
+ MI.getOperand(i+1).ChangeToImmediate(Offset);
+ return;
+ }
+
Offset += MI.getOperand(i-1).getImm();
DEBUG(errs() << "Offset : " << Offset << "\n" << "<--------->\n");
@@ -202,28 +232,7 @@ eliminateFrameIndex(MachineBasicBlock::iterator II, int SPAdj,
int NewImm = 0;
MachineBasicBlock &MBB = *MI.getParent();
bool ATUsed;
- unsigned FrameReg;
- const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
- int MinCSFI = 0;
- int MaxCSFI = -1;
-
- if (CSI.size()) {
- MinCSFI = CSI[0].getFrameIdx();
- MaxCSFI = CSI[CSI.size() - 1].getFrameIdx();
- }
- // The following stack frame objects are always referenced relative to $sp:
- // 1. Outgoing arguments.
- // 2. Pointer to dynamically allocated stack space.
- // 3. Locations for callee-saved registers.
- // Everything else is referenced relative to whatever register
- // getFrameRegister() returns.
- if (MipsFI->isOutArgFI(FrameIndex) || MipsFI->isDynAllocFI(FrameIndex) ||
- (FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI))
- FrameReg = Mips::SP;
- else
- FrameReg = getFrameRegister(MF);
-
// Offset fits in the 16-bit field
if (Offset < 0x8000 && Offset >= -0x8000) {
NewReg = FrameReg;