Skip to content

Commit

Permalink
[SystemZ][z/OS] Update lowerCall (#68259)
Browse files Browse the repository at this point in the history
This PR moves some calculation out of `LowerCall` and into
`SystemZXPLINKFrameLowering::processFunctionBeforeFrameFinalized`.
We need to make this change because LowerCall isn't invoked for
functions that don't have function calls, and it is required for some
tooling to work correctly. A function that does not make any calls is
required to allocate 32 bytes for the parameter area required by the
ABI. However, we allocate 64 bytes because this additional space is
utilized by certain tools, like the debugger.

Co-authored-by: Yusra Syeda <yusra.syeda@ibm.com>
  • Loading branch information
ysyeda and Yusra Syeda committed Oct 5, 2023
1 parent 941c75a commit 5c4d35d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 12 additions & 0 deletions llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,18 @@ void SystemZXPLINKFrameLowering::processFunctionBeforeFrameFinalized(

// Setup stack frame offset
MFFrame.setOffsetAdjustment(Regs.getStackPointerBias());

// Nothing to do for leaf functions.
uint64_t StackSize = MFFrame.estimateStackSize(MF);
if (StackSize == 0 && MFFrame.getCalleeSavedInfo().empty())
return;

// Although the XPLINK specifications for AMODE64 state that minimum size
// of the param area is minimum 32 bytes and no rounding is otherwise
// specified, we round this area in 64 bytes increments to be compatible
// with existing compilers.
MFFrame.setMaxCallFrameSize(
std::max(64U, (unsigned)alignTo(MFFrame.getMaxCallFrameSize(), 64)));
}

// Determines the size of the frame, and creates the deferred spill objects.
Expand Down
7 changes: 0 additions & 7 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1816,13 +1816,6 @@ SystemZTargetLowering::LowerCall(CallLoweringInfo &CLI,
// Get a count of how many bytes are to be pushed on the stack.
unsigned NumBytes = ArgCCInfo.getStackSize();

if (Subtarget.isTargetXPLINK64())
// Although the XPLINK specifications for AMODE64 state that minimum size
// of the param area is minimum 32 bytes and no rounding is otherwise
// specified, we round this area in 64 bytes increments to be compatible
// with existing compilers.
NumBytes = std::max(64U, (unsigned)alignTo(NumBytes, 64));

// Mark the start of the call.
if (!IsTailCall)
Chain = DAG.getCALLSEQ_START(Chain, NumBytes, 0, DL);
Expand Down

0 comments on commit 5c4d35d

Please sign in to comment.