summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-07-10 18:27:15 +0000
committerChad Rosier <mcrosier@apple.com>2012-07-10 18:27:15 +0000
commit97c22142779e47740e90e8ea3e0b74d8db46d6a1 (patch)
treed994d4b1c2ffc26f4becbbffc0bd9d25805be216 /llvm/lib
parenta29bdad954d5439e03ee5f3ac4f844b90be1411e (diff)
downloadbcm5719-llvm-97c22142779e47740e90e8ea3e0b74d8db46d6a1.tar.gz
bcm5719-llvm-97c22142779e47740e90e8ea3e0b74d8db46d6a1.zip
Move [get|set]BasePtrStackAdjustment() from MachineFrameInfo to
X86MachineFunctionInfo as this is currently only used by X86. If this ever becomes an issue on another arch (e.g., ARM) then we can hoist it back out. llvm-svn: 160009
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86FrameLowering.cpp4
-rw-r--r--llvm/lib/Target/X86/X86MachineFunctionInfo.h19
2 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 21ad062eda8..bf0ba09e23a 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -925,7 +925,7 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
.addReg(StackPtr)
.setMIFlag(MachineInstr::FrameSetup);
- MFI->setBasePtrStackAdjustment(NumBytes);
+ X86FI->setBasePtrStackAdjustment(NumBytes);
}
if (( (!HasFP && NumBytes) || PushedRegs) && needsFrameMoves) {
@@ -1051,7 +1051,7 @@ void X86FrameLowering::emitEpilogue(MachineFunction &MF,
StackPtr).addReg(BasePtr);
// When restoring from the BP we must use a cached SP adjustment.
- NumBytes = MFI->getBasePtrStackAdjustment();
+ NumBytes = X86FI->getBasePtrStackAdjustment();
}
// If dynamic alloca is used, then reset esp to point to the last callee-saved
diff --git a/llvm/lib/Target/X86/X86MachineFunctionInfo.h b/llvm/lib/Target/X86/X86MachineFunctionInfo.h
index 2bc308d86c5..cdf907b8c04 100644
--- a/llvm/lib/Target/X86/X86MachineFunctionInfo.h
+++ b/llvm/lib/Target/X86/X86MachineFunctionInfo.h
@@ -69,6 +69,10 @@ class X86MachineFunctionInfo : public MachineFunctionInfo {
/// NumLocalDynamics - Number of local-dynamic TLS accesses.
unsigned NumLocalDynamics;
+ /// After the stack pointer has been restore from the base pointer we
+ /// use a cached adjusment.
+ int64_t BPAdj;
+
public:
X86MachineFunctionInfo() : ForceFramePointer(false),
CalleeSavedFrameSize(0),
@@ -97,8 +101,9 @@ public:
VarArgsGPOffset(0),
VarArgsFPOffset(0),
ArgumentStackSize(0),
- NumLocalDynamics(0) {}
-
+ NumLocalDynamics(0),
+ BPAdj(0) {}
+
bool getForceFramePointer() const { return ForceFramePointer;}
void setForceFramePointer(bool forceFP) { ForceFramePointer = forceFP; }
@@ -137,6 +142,16 @@ public:
unsigned getNumLocalDynamicTLSAccesses() const { return NumLocalDynamics; }
void incNumLocalDynamicTLSAccesses() { ++NumLocalDynamics; }
+
+ /// setBasePtrStackAdjustment - If we're restoring the stack pointer from the
+ /// base pointer, due to dynamic stack realignment + VLAs, we cache the
+ /// number of bytes initially allocated for the stack frame. In obscure
+ /// cases (e.g., tail calls with byval argument and no stack protector), the
+ /// stack gets adjusted outside of the prolog, but these shouldn't be
+ /// considered when restoring from the base pointer. Currently, this is only
+ /// needed for x86.
+ void setBasePtrStackAdjustment(int64_t adj) { BPAdj = adj; }
+ int64_t getBasePtrStackAdjustment() const { return BPAdj; }
};
} // End llvm namespace
OpenPOWER on IntegriCloud