[llvm] [SystemZ][z/OS] Update lowerCall (PR #68259)

Yusra Syeda via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 14:01:46 PDT 2023


https://github.com/ysyeda created https://github.com/llvm/llvm-project/pull/68259

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.


>From 06f5102b8c5191566eac0eebd18ba48607d797a3 Mon Sep 17 00:00:00 2001
From: Yusra Syeda <yusra.syeda at ibm.com>
Date: Wed, 4 Oct 2023 16:55:45 -0400
Subject: [PATCH] update lowercall

---
 llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp | 12 ++++++++++++
 llvm/lib/Target/SystemZ/SystemZISelLowering.cpp  |  7 -------
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index 11a59df899a1a09..75a37060a8d06af 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -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.
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index da3129f08c28800..5c5cb964bd28db8 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -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);



More information about the llvm-commits mailing list