diff options
author | Chris Lattner <sabre@nondot.org> | 2003-01-15 22:57:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-01-15 22:57:35 +0000 |
commit | eafa42388160fa28621934392a7c5a22dbea54d0 (patch) | |
tree | e3716807b6f6ba1e90201c6b9c92910fbd9b7a72 | |
parent | 4ac7d7302b36a5d20f71b5c290c63a7f6c345289 (diff) |
Handle frame offset due to return address pushed on the stack
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5319 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86RegisterInfo.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index 821a4735cf..ed347c21a0 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -138,11 +138,11 @@ void X86RegisterInfo::eliminateFrameIndex(MachineFunction &MF, // 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::processFunctionBeforeFrameFinalized(MachineFunction &MF) 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 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { 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 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const { // 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 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF, 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 @@ void X86RegisterInfo::emitEpilogue(MachineFunction &MF, // 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); |