[llvm] 8a7a2da - [SystemZ][z/OS] Correct value of length/4 of params field in PPA1.

Neumann Hon via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 10:38:37 PDT 2023


Author: Neumann Hon
Date: 2023-06-14T13:37:46-04:00
New Revision: 8a7a2da18f9add7fb58fe707e4f0256e3abeb8fa

URL: https://github.com/llvm/llvm-project/commit/8a7a2da18f9add7fb58fe707e4f0256e3abeb8fa
DIFF: https://github.com/llvm/llvm-project/commit/8a7a2da18f9add7fb58fe707e4f0256e3abeb8fa.diff

LOG: [SystemZ][z/OS] Correct value of length/4 of params field in PPA1.

The Length/4 of Params field in the PPA1 ought to be the length of the parameters for the current function. Currently we are storing the length of the parameter area in the current function's stack frame, which represents the length of the params of the longest callee in the current function.

Differential Revision: https://reviews.llvm.org/D152920

Reviewed By: uweigand

Added: 
    

Modified: 
    llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
    llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
    llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h
    llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
index 2bfde5130c820..b24eade5b5d34 100644
--- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -1058,7 +1058,7 @@ void SystemZAsmPrinter::emitPPA1(MCSymbol *FnEndSym) {
 
   OutStreamer->AddComment("Length/4 of Parms");
   OutStreamer->emitInt16(
-      static_cast<uint16_t>(MFFrame.getMaxCallFrameSize() / 4)); // Parms/4.
+      static_cast<uint16_t>(ZFI->getSizeOfFnParams() / 4)); // Parms/4.
   OutStreamer->AddComment("Length of Code");
   OutStreamer->emitAbsoluteSymbolDiff(FnEndSym, CurrentFnEPMarkerSym, 4);
 

diff  --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 643b529b13fd2..c50e9398a8b16 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -1505,6 +1505,7 @@ SDValue SystemZTargetLowering::LowerFormalArguments(
   SmallVector<CCValAssign, 16> ArgLocs;
   SystemZCCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
   CCInfo.AnalyzeFormalArguments(Ins, CC_SystemZ);
+  FuncInfo->setSizeOfFnParams(CCInfo.getStackSize());
 
   unsigned NumFixedGPRs = 0;
   unsigned NumFixedFPRs = 0;

diff  --git a/llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h b/llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h
index 333195989a117..7a0802abb2765 100644
--- a/llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h
+++ b/llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h
@@ -27,6 +27,9 @@ struct GPRRegs {
 class SystemZMachineFunctionInfo : public MachineFunctionInfo {
   virtual void anchor();
 
+  /// Size of expected parameter area for current function. (Fixed args only).
+  unsigned SizeOfFnParams;
+
   SystemZ::GPRRegs SpillGPRRegs;
   SystemZ::GPRRegs RestoreGPRRegs;
   Register VarArgsFirstGPR;
@@ -38,14 +41,20 @@ class SystemZMachineFunctionInfo : public MachineFunctionInfo {
 
 public:
   SystemZMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI)
-      : VarArgsFirstGPR(0), VarArgsFirstFPR(0), VarArgsFrameIndex(0),
-        RegSaveFrameIndex(0), FramePointerSaveIndex(0), NumLocalDynamics(0) {}
+      : SizeOfFnParams(0), VarArgsFirstGPR(0), VarArgsFirstFPR(0),
+        VarArgsFrameIndex(0), RegSaveFrameIndex(0), FramePointerSaveIndex(0),
+        NumLocalDynamics(0) {}
 
   MachineFunctionInfo *
   clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF,
         const DenseMap<MachineBasicBlock *, MachineBasicBlock *> &Src2DstMBB)
       const override;
 
+  // z/OS: Get and set the size of the expected parameter area for the
+  // current function. (ie. Size of param area in caller).
+  unsigned getSizeOfFnParams() const { return SizeOfFnParams; }
+  void setSizeOfFnParams(unsigned Size) { SizeOfFnParams = Size; }
+
   // Get and set the first and last call-saved GPR that should be saved by
   // this function and the SP offset for the STMG.  These are 0 if no GPRs
   // need to be saved or restored.

diff  --git a/llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll b/llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll
index 13224c01ca9a1..6b8c3bf53122d 100644
--- a/llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll
+++ b/llvm/test/CodeGen/SystemZ/zos-prologue-epilog.ll
@@ -14,6 +14,9 @@
 ; CHECK64: lg  7, 2072(4)
 ; CHECK64: aghi  4, 192
 ; CHECK64: b 2(7)
+
+; CHECK64: @@PPA1_func0_0:
+; CHECK64: .short	0  * Length/4 of Parms
 define void @func0() {
   call i64 (i64) @fun(i64 10) 
   ret void
@@ -27,6 +30,9 @@ define void @func0() {
 ; CHECK64: lmg 7, 15, 2072(4)
 ; CHECK64: aghi  4, 160
 ; CHECK64: b 2(7)
+
+; CHECK64: @@PPA1_func1_0:
+; CHECK64: .short	2  * Length/4 of Parms
 define void @func1(ptr %ptr) {
   %l01 = load volatile i64, ptr %ptr
   %l02 = load volatile i64, ptr %ptr
@@ -338,6 +344,9 @@ define void @large_stack0() {
 ; CHECK64: @BB7_2:
 ; CHECK64: stmg  6, 7, 2064(4)
 ; CHECK64: lgr 3, 0
+
+; CHECK64: @@PPA1_large_stack1_0:
+; CHECK64: .short	6  * Length/4 of Parms
 define void @large_stack1(i64 %n1, i64 %n2, i64 %n3) {
   %arr = alloca [131072 x i64], align 8
   call i64 (ptr, i64, i64, i64) @fun3(ptr %arr,


        


More information about the llvm-commits mailing list