[llvm] 80584f0 - Revert "[PowerPC][ELF] make sure local variable space does not overlap with parameter save area"

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 17 01:07:51 PDT 2021


Author: Chen Zheng
Date: 2021-09-17T08:07:18Z
New Revision: 80584f00564630a9edf51f74049b4eeaff4549b1

URL: https://github.com/llvm/llvm-project/commit/80584f00564630a9edf51f74049b4eeaff4549b1
DIFF: https://github.com/llvm/llvm-project/commit/80584f00564630a9edf51f74049b4eeaff4549b1.diff

LOG: Revert "[PowerPC][ELF] make sure local variable space does not overlap with parameter save area"

This causes mix-compile issues on PowerPC Linux.

This reverts commit 324bd467a217d89b5ab84a8ed66c0d3dc431782a.

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/PPCISelLowering.cpp
    llvm/test/CodeGen/PowerPC/byval.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index 85b62f61a4d87..f27219f2f09b7 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -3883,8 +3883,7 @@ static Align CalculateStackSlotAlignment(EVT ArgVT, EVT OrigVT,
 /// stack slot (instead of being passed in registers).  ArgOffset,
 /// AvailableFPRs, and AvailableVRs must hold the current argument
 /// position, and will be updated to account for this argument.
-static bool CalculateStackSlotUsed(const PPCSubtarget &Subtarget, EVT ArgVT,
-                                   EVT OrigVT, ISD::ArgFlagsTy Flags,
+static bool CalculateStackSlotUsed(EVT ArgVT, EVT OrigVT, ISD::ArgFlagsTy Flags,
                                    unsigned PtrByteSize, unsigned LinkageSize,
                                    unsigned ParamAreaSize, unsigned &ArgOffset,
                                    unsigned &AvailableFPRs,
@@ -3925,13 +3924,7 @@ static bool CalculateStackSlotUsed(const PPCSubtarget &Subtarget, EVT ArgVT,
         --AvailableVRs;
         return false;
       }
-  } else if (Subtarget.isPPC64() && Subtarget.isELFv2ABI() &&
-             Flags.getByValSize() >= 8)
-    // For 64-bit ELF v2, passing by value object whose size is no less than 8
-    // bytes will be copied to parameter save area. This is for compatibility
-    // for other compiler which requires byval parameters to be stored in
-    // caller's parameter save area.
-    return true;
+  }
 
   return UseMemory;
 }
@@ -4274,7 +4267,7 @@ SDValue PPCTargetLowering::LowerFormalArguments_64SVR4(
     if (Ins[i].Flags.isNest())
       continue;
 
-    if (CalculateStackSlotUsed(Subtarget, Ins[i].VT, Ins[i].ArgVT, Ins[i].Flags,
+    if (CalculateStackSlotUsed(Ins[i].VT, Ins[i].ArgVT, Ins[i].Flags,
                                PtrByteSize, LinkageSize, ParamAreaSize,
                                NumBytes, AvailableFPRs, AvailableVRs))
       HasParameterArea = true;
@@ -4735,9 +4728,9 @@ needStackSlotPassParameters(const PPCSubtarget &Subtarget,
   for (const ISD::OutputArg& Param : Outs) {
     if (Param.Flags.isNest()) continue;
 
-    if (CalculateStackSlotUsed(Subtarget, Param.VT, Param.ArgVT, Param.Flags,
-                               PtrByteSize, LinkageSize, ParamAreaSize,
-                               NumBytes, AvailableFPRs, AvailableVRs))
+    if (CalculateStackSlotUsed(Param.VT, Param.ArgVT, Param.Flags, PtrByteSize,
+                               LinkageSize, ParamAreaSize, NumBytes,
+                               AvailableFPRs, AvailableVRs))
       return true;
   }
   return false;
@@ -5973,10 +5966,9 @@ SDValue PPCTargetLowering::LowerCall_64SVR4(
     unsigned NumBytesTmp = NumBytes;
     for (unsigned i = 0; i != NumOps; ++i) {
       if (Outs[i].Flags.isNest()) continue;
-      if (CalculateStackSlotUsed(Subtarget, Outs[i].VT, Outs[i].ArgVT,
-                                 Outs[i].Flags, PtrByteSize, LinkageSize,
-                                 ParamAreaSize, NumBytesTmp, AvailableFPRs,
-                                 AvailableVRs))
+      if (CalculateStackSlotUsed(Outs[i].VT, Outs[i].ArgVT, Outs[i].Flags,
+                                 PtrByteSize, LinkageSize, ParamAreaSize,
+                                 NumBytesTmp, AvailableFPRs, AvailableVRs))
         HasParameterArea = true;
     }
   }

diff  --git a/llvm/test/CodeGen/PowerPC/byval.ll b/llvm/test/CodeGen/PowerPC/byval.ll
index e6ad0f438c510..c67cc1022695f 100644
--- a/llvm/test/CodeGen/PowerPC/byval.ll
+++ b/llvm/test/CodeGen/PowerPC/byval.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -verify-machineinstrs < %s | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512"
@@ -8,15 +9,15 @@ target triple = "powerpc64le-unknown-linux-gnu"
 declare dso_local i32 @foo1(%struct* byval(%struct) %var)
 declare dso_local void @foo(%struct* %var)
 
-; for the byval parameter %x, make sure the memory for local variable and
-; for parameter save area are not overlap.
+; FIXME: for the byval parameter %x, now the memory for local variable and
+; for parameter save area are overlap.
 ; For the below case,
-; the local variable space is r1 + 104 ~ r1 + 140
+; the local variable space is r1 + 40 ~ r1 + 76
 ; the parameter save area is r1 + 32 ~ r1 + 68
 
 define dso_local i32 @bar() {
 ; CHECK-LABEL: bar:
-; CHECK:    addi 30, 1, 104
+; CHECK:    addi 30, 1, 40
 ; CHECK:    li 3, 16
 ; CHECK:    lxvd2x 0, 30, 3
 ; CHECK:    li 3, 48
@@ -24,7 +25,7 @@ define dso_local i32 @bar() {
 ; CHECK:    li 3, 32
 ; CHECK:    lxvd2x 0, 0, 30
 ; CHECK:    stxvd2x 0, 1, 3
-; CHECK:    lwz 3, 136(1)
+; CHECK:    lwz 3, 72(1)
 ; CHECK:    stw 3, 64(1)
 entry:
   %x = alloca %struct, align 4


        


More information about the llvm-commits mailing list