[PATCH] D105271: [PowerPC][ELF]make sure local variable space does not overlap with parameter save area
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 1 02:50:14 PDT 2021
shchenz created this revision.
shchenz added reviewers: jsji, uweigand, sfertile, nemanjai, PowerPC.
Herald added subscribers: kbarton, hiraditya.
shchenz requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is a bug fix for byval parameter passing in the caller site.
Currently in the caller site, `byval` parameter which size is not smaller than 8 will be stored into parameter save area.
See:
LowerCall_64SVR4 -> createMemcpyOutsideCallSeq()
But in the previous `HasParameterArea` checking, it is not set to true. So this will cause the stack memory for local variable space and parameter save area overlap.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105271
Files:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/byval.ll
Index: llvm/test/CodeGen/PowerPC/byval.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/byval.ll
+++ llvm/test/CodeGen/PowerPC/byval.ll
@@ -9,15 +9,15 @@
declare dso_local i32 @foo1(%struct* byval(%struct) %var)
declare dso_local void @foo(%struct* %var)
-; FIXME: for the byval parameter %x, now the memory for local variable and
-; for parameter save area are overlap.
+; for the byval parameter %x, make sure the memory for local variable and
+; for parameter save area are not overlap.
; For the below case,
-; the local variable space is r1 + 40 ~ r1 + 76
+; the local variable space is r1 + 104 ~ r1 + 140
; the parameter save area is r1 + 32 ~ r1 + 68
define dso_local i32 @bar() {
; CHECK-LABEL: bar:
-; CHECK: addi 30, 1, 40
+; CHECK: addi 30, 1, 104
; CHECK: li 3, 16
; CHECK: lxvd2x 0, 30, 3
; CHECK: li 3, 48
@@ -25,7 +25,7 @@
; CHECK: li 3, 32
; CHECK: lxvd2x 0, 0, 30
; CHECK: stxvd2x 0, 1, 3
-; CHECK: lwz 3, 72(1)
+; CHECK: lwz 3, 136(1)
; CHECK: stw 3, 64(1)
entry:
%x = alloca %struct, align 4
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -6015,7 +6015,8 @@
}
HasParameterArea = true;
}
- }
+ } else if (Flags.isByVal() && Flags.getByValSize() >= 8)
+ HasParameterArea = true;
/* Respect alignment of argument on the stack. */
auto Alignement =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105271.355808.patch
Type: text/x-patch
Size: 1591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210701/97a431a4/attachment.bin>
More information about the llvm-commits
mailing list