summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2018-03-02 20:38:41 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2018-03-02 20:38:41 +0000
commit32063888700f57bf57ede4f24efb727fd3f284c5 (patch)
tree9dd67ed03061f0555db86ba467a1b715c4608221 /llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
parent18f6930fef2d76a9dc62409213eba9d851f1b350 (diff)
downloadbcm5719-llvm-32063888700f57bf57ede4f24efb727fd3f284c5.tar.gz
bcm5719-llvm-32063888700f57bf57ede4f24efb727fd3f284c5.zip
[SystemZ] Fix common-code users of stack size
On SystemZ we need to provide a register save area of 160 bytes to any called function. This size needs to be added when allocating stack in the function prologue. However, it was not accounted for as part of MachineFrameInfo::getStackSize(); instead the back-end used a private routine getAllocatedStackSize(). This is OK for code-gen purposes, but it breaks other users of the getStackSize() routine, in particular it breaks the recently- added -stack-size-section feature. Fix this by updating the main stack size tracked by common code (in emitPrologue) instead of using the private routine. No change in code generation intended. llvm-svn: 326610
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp53
1 files changed, 11 insertions, 42 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index b600aa61cd0..b2d59b1706d 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -371,7 +371,15 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF,
}
}
- uint64_t StackSize = getAllocatedStackSize(MF);
+ uint64_t StackSize = MFFrame.getStackSize();
+ // We need to allocate the ABI-defined 160-byte base area whenever
+ // we allocate stack space for our own use and whenever we call another
+ // function.
+ if (StackSize || MFFrame.hasVarSizedObjects() || MFFrame.hasCalls()) {
+ StackSize += SystemZMC::CallFrameSize;
+ MFFrame.setStackSize(StackSize);
+ }
+
if (StackSize) {
// Determine if we want to store a backchain.
bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
@@ -454,11 +462,12 @@ void SystemZFrameLowering::emitEpilogue(MachineFunction &MF,
auto *ZII =
static_cast<const SystemZInstrInfo *>(MF.getSubtarget().getInstrInfo());
SystemZMachineFunctionInfo *ZFI = MF.getInfo<SystemZMachineFunctionInfo>();
+ MachineFrameInfo &MFFrame = MF.getFrameInfo();
// Skip the return instruction.
assert(MBBI->isReturn() && "Can only insert epilogue into returning blocks");
- uint64_t StackSize = getAllocatedStackSize(MF);
+ uint64_t StackSize = MFFrame.getStackSize();
if (ZFI->getLowSavedGPR()) {
--MBBI;
unsigned Opcode = MBBI->getOpcode();
@@ -495,46 +504,6 @@ bool SystemZFrameLowering::hasFP(const MachineFunction &MF) const {
MF.getInfo<SystemZMachineFunctionInfo>()->getManipulatesSP());
}
-int SystemZFrameLowering::getFrameIndexReference(const MachineFunction &MF,
- int FI,
- unsigned &FrameReg) const {
- const MachineFrameInfo &MFFrame = MF.getFrameInfo();
- const TargetRegisterInfo *RI = MF.getSubtarget().getRegisterInfo();
-
- // Fill in FrameReg output argument.
- FrameReg = RI->getFrameRegister(MF);
-
- // Start with the offset of FI from the top of the caller-allocated frame
- // (i.e. the top of the 160 bytes allocated by the caller). This initial
- // offset is therefore negative.
- int64_t Offset = (MFFrame.getObjectOffset(FI) +
- MFFrame.getOffsetAdjustment());
-
- // Make the offset relative to the incoming stack pointer.
- Offset -= getOffsetOfLocalArea();
-
- // Make the offset relative to the bottom of the frame.
- Offset += getAllocatedStackSize(MF);
-
- return Offset;
-}
-
-uint64_t SystemZFrameLowering::
-getAllocatedStackSize(const MachineFunction &MF) const {
- const MachineFrameInfo &MFFrame = MF.getFrameInfo();
-
- // Start with the size of the local variables and spill slots.
- uint64_t StackSize = MFFrame.getStackSize();
-
- // We need to allocate the ABI-defined 160-byte base area whenever
- // we allocate stack space for our own use and whenever we call another
- // function.
- if (StackSize || MFFrame.hasVarSizedObjects() || MFFrame.hasCalls())
- StackSize += SystemZMC::CallFrameSize;
-
- return StackSize;
-}
-
bool
SystemZFrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
// The ABI requires us to allocate 160 bytes of stack space for the callee,
OpenPOWER on IntegriCloud