}
}
- 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");
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();
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,
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
bool hasFP(const MachineFunction &MF) const override;
- int getFrameIndexReference(const MachineFunction &MF, int FI,
- unsigned &FrameReg) const override;
bool hasReservedCallFrame(const MachineFunction &MF) const override;
MachineBasicBlock::iterator
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI) const override;
- // Return the number of bytes in the callee-allocated part of the frame.
- uint64_t getAllocatedStackSize(const MachineFunction &MF) const;
-
// Return the byte offset from the incoming stack pointer of Reg's
// ABI-defined save slot. Return 0 if no slot is defined for Reg.
unsigned getRegSpillOffset(unsigned Reg) const {
--- /dev/null
+; RUN: llc < %s -mtriple=s390x-linux-gnu -stack-size-section | FileCheck %s
+
+; CHECK-LABEL: func1:
+; CHECK: .section .stack_sizes,"",@progbits
+; CHECK-NEXT: .quad func1
+; CHECK-NEXT: .byte 0
+define void @func1(i32, i32) #0 {
+ ret void
+}
+
+; CHECK-LABEL: func2:
+; CHECK: .section .stack_sizes,"",@progbits
+; CHECK-NEXT: .quad func2
+; CHECK-NEXT: .ascii "\250\001"
+define void @func2(i32, i32) #0 {
+ alloca i32, align 4
+ alloca i32, align 4
+ ret void
+}
+
+; CHECK-LABEL: func3:
+; CHECK: .section .stack_sizes,"",@progbits
+; CHECK-NEXT: .quad func3
+; CHECK-NEXT: .ascii "\250\001"
+define void @func3() #0 {
+ alloca i32, align 4
+ call void @func1(i32 1, i32 2)
+ ret void
+}
+
+; CHECK-LABEL: dynalloc:
+; CHECK-NOT: .section .stack_sizes
+define void @dynalloc(i32 %N) #0 {
+ alloca i32, i32 %N
+ ret void
+}
+
+attributes #0 = { "no-frame-pointer-elim"="true" }