[llvm] d52bb6d - [PowerPC][AIX] ByVal formal argument support: passing on the stack.
Sean Fertile via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 20 09:05:39 PDT 2020
Author: Sean Fertile
Date: 2020-04-20T12:04:59-04:00
New Revision: d52bb6d099d32156dc9983f7438e1aac132c77af
URL: https://github.com/llvm/llvm-project/commit/d52bb6d099d32156dc9983f7438e1aac132c77af
DIFF: https://github.com/llvm/llvm-project/commit/d52bb6d099d32156dc9983f7438e1aac132c77af.diff
LOG: [PowerPC][AIX] ByVal formal argument support: passing on the stack.
Adds support for passing a ByVal formal argument completely on the stack
(ie after all argument registers are exhausted).
Differential Revision: https://reviews.llvm.org/D78263
Added:
Modified:
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/test/CodeGen/PowerPC/aix-cc-byval-mem.ll
Removed:
llvm/test/CodeGen/PowerPC/aix-cc-byval-limitation2.ll
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index c9bd6e845450..c90dec260d28 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -7141,12 +7141,11 @@ SDValue PPCTargetLowering::LowerFormalArguments_AIX(
continue;
if (Flags.isByVal() && VA.isMemLoc()) {
- if (Flags.getByValSize() != 0)
- report_fatal_error(
- "ByVal arguments passed on stack not implemented yet");
-
+ const unsigned Size =
+ alignTo(Flags.getByValSize() ? Flags.getByValSize() : PtrByteSize,
+ PtrByteSize);
const int FI = MF.getFrameInfo().CreateFixedObject(
- PtrByteSize, VA.getLocMemOffset(), /* IsImmutable */ false,
+ Size, VA.getLocMemOffset(), /* IsImmutable */ false,
/* IsAliased */ true);
SDValue FIN = DAG.getFrameIndex(FI, PtrVT);
InVals.push_back(FIN);
diff --git a/llvm/test/CodeGen/PowerPC/aix-cc-byval-limitation2.ll b/llvm/test/CodeGen/PowerPC/aix-cc-byval-limitation2.ll
deleted file mode 100644
index e78d5957fce0..000000000000
--- a/llvm/test/CodeGen/PowerPC/aix-cc-byval-limitation2.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: not --crash llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
-; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s
-
-%struct.S = type { i8 }
-
-define void @foo(i32 %i1, i32 %i2, i32 %i3, i32 %i4, i32 %i5, i32 %i6, i32 %i7, i32 %i8, %struct.S* byval(%struct.S) align 1 %s) {
-entry:
- ret void
-}
-
-; CHECK: LLVM ERROR: ByVal arguments passed on stack not implemented yet
diff --git a/llvm/test/CodeGen/PowerPC/aix-cc-byval-mem.ll b/llvm/test/CodeGen/PowerPC/aix-cc-byval-mem.ll
index dd5574438a9d..4dbe114956dc 100644
--- a/llvm/test/CodeGen/PowerPC/aix-cc-byval-mem.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-cc-byval-mem.ll
@@ -22,11 +22,10 @@
define void @call_test_byval_mem1() {
entry:
- call void @test_byval_mem1(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, %struct_S1* byval(%struct_S1) align 1 @gS1)
+ %call = call zeroext i8 @test_byval_mem1(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, %struct_S1* byval(%struct_S1) align 1 @gS1)
ret void
}
-declare void @test_byval_mem1(i32, i32, i32, i32, i32, i32, i32, i32, %struct_S1* byval(%struct_S1) align 1)
; CHECKASM-LABEL: .call_test_byval_mem1:
@@ -44,6 +43,29 @@ declare void @test_byval_mem1(i32, i32, i32, i32, i32, i32, i32, i32, %struct_S1
; ASM64BIT: bl .test_byval_mem1
; ASM64BIT: addi 1, 1, 128
+define zeroext i8 @test_byval_mem1(i32, i32, i32, i32, i32, i32, i32, i32, %struct_S1* byval(%struct_S1) align 1 %s) {
+entry:
+ %gep = getelementptr inbounds %struct_S1, %struct_S1* %s, i32 0, i32 0
+ %load = load i8, i8* %gep, align 1
+ ret i8 %load
+}
+
+; CHECK-LABEL: name: test_byval_mem1
+
+; 32BIT: fixedStack:
+; 32BIT-NEXT: - { id: 0, type: default, offset: 56, size: 4, alignment: 8, stack-id: default,
+; 32BIT: bb.0.entry:
+; 32BIT-NEXT: %[[VAL:[0-9]+]]:gprc = LBZ 0, %fixed-stack.0
+; 32BIT-NEXT: $r3 = COPY %[[VAL]]
+; 32BIT-NEXT: BLR
+
+; 64BIT: fixedStack:
+; 64BIT-NEXT: - { id: 0, type: default, offset: 112, size: 8, alignment: 16, stack-id: default,
+; 64BIT: bb.0.entry:
+; 64BIT-NEXT: %[[VAL:[0-9]+]]:g8rc = LBZ8 0, %fixed-stack.0
+; 64BIT-NEXT: $x3 = COPY %[[VAL]]
+; 64BIT-NEXT: BLR8
+
%struct_S256 = type { [256 x i8] }
@@ -51,11 +73,10 @@ declare void @test_byval_mem1(i32, i32, i32, i32, i32, i32, i32, i32, %struct_S1
define void @call_test_byval_mem2() {
entry:
- call void @test_byval_mem2(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, %struct_S256* byval(%struct_S256) align 1 @gS256)
+ %call = call zeroext i8 @test_byval_mem2(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, %struct_S256* byval(%struct_S256) align 1 @gS256)
ret void
}
-declare void @test_byval_mem2(i32, i32, i32, i32, i32, i32, i32, i32, %struct_S256* byval(%struct_S256) align 1)
; CHECK-LABEL: name: call_test_byval_mem2
@@ -122,6 +143,29 @@ declare void @test_byval_mem2(i32, i32, i32, i32, i32, i32, i32, i32, %struct_S2
; ASM64BIT: addi 1, 1, 368
+define zeroext i8 @test_byval_mem2(i32, i32, i32, i32, i32, i32, i32, i32, %struct_S256* byval(%struct_S256) align 1 %s) {
+entry:
+ %gep = getelementptr inbounds %struct_S256, %struct_S256* %s, i32 0, i32 0, i32 255
+ %load = load i8, i8* %gep, align 1
+ ret i8 %load
+}
+
+; CHECK-LABEL: name: test_byval_mem2
+
+; 32BIT: fixedStack:
+; 32BIT-NEXT: - { id: 0, type: default, offset: 56, size: 256, alignment: 8, stack-id: default,
+; 32BIT: bb.0.entry:
+; 32BIT-NEXT: %[[VAL:[0-9]+]]:gprc = LBZ 255, %fixed-stack.0
+; 32BIT-NEXT: $r3 = COPY %[[VAL]]
+; 32BIT-NEXT: BLR
+
+; 64BIT: fixedStack:
+; 64BIT-NEXT: - { id: 0, type: default, offset: 112, size: 256, alignment: 16, stack-id: default,
+; 64BIT: bb.0.entry:
+; 64BIT-NEXT: %[[VAL:[0-9]+]]:g8rc = LBZ8 255, %fixed-stack.0
+; 64BIT-NEXT: $x3 = COPY %[[VAL]]
+; 64BIT-NEXT: BLR8
+
%struct_S57 = type { [57 x i8] }
@gS57 = external global %struct_S57, align 1
More information about the llvm-commits
mailing list