[llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jan 15 16:58:00 PST 2003
Changes in directory llvm/lib/Target/X86:
X86RegisterInfo.cpp updated: 1.28 -> 1.29
---
Log message:
Handle frame offset due to return address pushed on the stack
---
Diffs of the changes:
Index: llvm/lib/Target/X86/X86RegisterInfo.cpp
diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.28 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.29
--- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.28 Sun Jan 12 18:50:33 2003
+++ llvm/lib/Target/X86/X86RegisterInfo.cpp Wed Jan 15 16:57:35 2003
@@ -138,11 +138,11 @@
// Now add the frame object offset to the offset from EBP.
int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
- MI.getOperand(i+3).getImmedValue();
+ MI.getOperand(i+3).getImmedValue()+4;
if (!hasFP(MF) && hasSPAdjust(MF)) {
const MachineFrameInfo *MFI = MF.getFrameInfo();
- Offset += MFI->getStackSize() + MFI->getMaxCallFrameSize();
+ Offset += MFI->getStackSize();
}
MI.SetMachineOperandConst(i+3, MachineOperand::MO_SignExtendedImmed, Offset);
@@ -161,7 +161,7 @@
void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
MachineBasicBlock &MBB = MF.front(); // Prolog goes in entry BB
MachineBasicBlock::iterator MBBI = MBB.begin();
- const MachineFrameInfo *MFI = MF.getFrameInfo();
+ MachineFrameInfo *MFI = MF.getFrameInfo();
MachineInstr *MI;
// Get the number of bytes to allocate from the FrameInfo
@@ -169,7 +169,7 @@
if (hasFP(MF)) {
// Get the offset of the stack slot for the EBP register... which is
// guaranteed to be the last slot by processFunctionBeforeFrameFinalized.
- int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1);
+ int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1)+4;
MI = addRegOffset(BuildMI(X86::MOVrm32, 5), // mov [ESP-<offset>], EBP
X86::ESP, EBPOffset).addReg(X86::EBP);
@@ -190,6 +190,9 @@
// eliminates the need for add/sub ESP brackets around call sites.
//
NumBytes += MFI->getMaxCallFrameSize();
+
+ // Update frame info to pretend that this is part of the stack...
+ MFI->setStackSize(NumBytes);
}
if (NumBytes) {
@@ -210,7 +213,7 @@
if (hasFP(MF)) {
// Get the offset of the stack slot for the EBP register... which is
// guaranteed to be the last slot by processFunctionBeforeFrameFinalized.
- int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1);
+ int EBPOffset = MFI->getObjectOffset(MFI->getObjectIndexEnd()-1)+4;
// mov ESP, EBP
MI = BuildMI(X86::MOVrr32, 1,X86::ESP).addReg(X86::EBP);
@@ -224,7 +227,6 @@
// Get the number of bytes allocated from the FrameInfo...
unsigned NumBytes = MFI->getStackSize();
- NumBytes += MFI->getMaxCallFrameSize();
if (NumBytes) { // adjust stack pointer back: ESP += numbytes
MI =BuildMI(X86::ADDri32, 2, X86::ESP).addReg(X86::ESP).addZImm(NumBytes);
More information about the llvm-commits
mailing list