Generate more correct debug info for frame indices.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89576 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach 2009-11-22 02:32:29 +00:00
parent 1722f061a3
commit 50f8516d2d
2 changed files with 53 additions and 35 deletions

View File

@ -799,6 +799,53 @@ ARMBaseRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
return ARM::SP; return ARM::SP;
} }
int
ARMBaseRegisterInfo::getFrameIndexReference(MachineFunction &MF, int FI,
unsigned &FrameReg) const {
const MachineFrameInfo *MFI = MF.getFrameInfo();
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
int Offset = MFI->getObjectOffset(FI) + MFI->getStackSize();
bool isFixed = MFI->isFixedObjectIndex(FI);
if (AFI->isGPRCalleeSavedArea1Frame(FI))
Offset -= AFI->getGPRCalleeSavedArea1Offset();
else if (AFI->isGPRCalleeSavedArea2Frame(FI))
Offset -= AFI->getGPRCalleeSavedArea2Offset();
else if (AFI->isDPRCalleeSavedAreaFrame(FI))
Offset -= AFI->getDPRCalleeSavedAreaOffset();
else if (needsStackRealignment(MF)) {
// When dynamically realigning the stack, use the frame pointer for
// parameters, and the stack pointer for locals.
assert (hasFP(MF) && "dynamic stack realignment without a FP!");
if (isFixed) {
FrameReg = getFrameRegister(MF);
Offset -= AFI->getFramePtrSpillOffset();
}
} else if (hasFP(MF) && AFI->hasStackFrame()) {
if (isFixed || MFI->hasVarSizedObjects()) {
// Use frame pointer to reference fixed objects unless this is a
// frameless function.
FrameReg = getFrameRegister(MF);
Offset -= AFI->getFramePtrSpillOffset();
} else if (AFI->isThumb2Function()) {
// In Thumb2 mode, the negative offset is very limited.
int FPOffset = Offset - AFI->getFramePtrSpillOffset();
if (FPOffset >= -255 && FPOffset < 0) {
FrameReg = getFrameRegister(MF);
Offset = FPOffset;
}
}
}
return Offset;
}
int
ARMBaseRegisterInfo::getFrameIndexOffset(MachineFunction &MF, int FI) const {
unsigned FrameReg;
return getFrameIndexReference(MF, FI, FrameReg);
}
unsigned ARMBaseRegisterInfo::getEHExceptionRegister() const { unsigned ARMBaseRegisterInfo::getEHExceptionRegister() const {
llvm_unreachable("What is the exception register"); llvm_unreachable("What is the exception register");
return 0; return 0;
@ -1118,42 +1165,10 @@ ARMBaseRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
unsigned FrameReg = ARM::SP; unsigned FrameReg = ARM::SP;
int FrameIndex = MI.getOperand(i).getIndex(); int FrameIndex = MI.getOperand(i).getIndex();
int Offset = MFI->getObjectOffset(FrameIndex) + MFI->getStackSize() + SPAdj; int Offset = MFI->getObjectOffset(FrameIndex) + MFI->getStackSize() + SPAdj;
bool isFixed = MFI->isFixedObjectIndex(FrameIndex);
// When doing dynamic stack realignment, all of these need to change(?) Offset = getFrameIndexReference(MF, FrameIndex, FrameReg);
if (AFI->isGPRCalleeSavedArea1Frame(FrameIndex)) if (FrameReg != ARM::SP)
Offset -= AFI->getGPRCalleeSavedArea1Offset(); SPAdj = 0;
else if (AFI->isGPRCalleeSavedArea2Frame(FrameIndex))
Offset -= AFI->getGPRCalleeSavedArea2Offset();
else if (AFI->isDPRCalleeSavedAreaFrame(FrameIndex))
Offset -= AFI->getDPRCalleeSavedAreaOffset();
else if (needsStackRealignment(MF)) {
// When dynamically realigning the stack, use the frame pointer for
// parameters, and the stack pointer for locals.
assert (hasFP(MF) && "dynamic stack realignment without a FP!");
if (isFixed) {
FrameReg = getFrameRegister(MF);
Offset -= AFI->getFramePtrSpillOffset();
// When referencing from the frame pointer, stack pointer adjustments
// don't matter.
SPAdj = 0;
}
} else if (hasFP(MF) && AFI->hasStackFrame()) {
assert(SPAdj == 0 && "Unexpected stack offset!");
if (isFixed || MFI->hasVarSizedObjects()) {
// Use frame pointer to reference fixed objects unless this is a
// frameless function.
FrameReg = getFrameRegister(MF);
Offset -= AFI->getFramePtrSpillOffset();
} else if (AFI->isThumb2Function()) {
// In Thumb2 mode, the negative offset is very limited.
int FPOffset = Offset - AFI->getFramePtrSpillOffset();
if (FPOffset >= -255 && FPOffset < 0) {
FrameReg = getFrameRegister(MF);
Offset = FPOffset;
}
}
}
// Modify MI as necessary to handle as much of 'Offset' as possible // Modify MI as necessary to handle as much of 'Offset' as possible
bool Done = false; bool Done = false;

View File

@ -106,6 +106,9 @@ public:
// Debug information queries. // Debug information queries.
unsigned getRARegister() const; unsigned getRARegister() const;
unsigned getFrameRegister(const MachineFunction &MF) const; unsigned getFrameRegister(const MachineFunction &MF) const;
int getFrameIndexReference(MachineFunction &MF, int FI,
unsigned &FrameReg) const;
int getFrameIndexOffset(MachineFunction &MF, int FI) const;
// Exception handling queries. // Exception handling queries.
unsigned getEHExceptionRegister() const; unsigned getEHExceptionRegister() const;