blob: b0e41ec29e4f84e92ae4828c6dbf563fe66a2a44 [file] [log] [blame]
Ehsan Amiria538b0f2016-08-03 18:17:35 +00001; RUN: llc -verify-machineinstrs -mcpu=pwr7 -O0 -fast-isel=false < %s | FileCheck %s
Bill Schmidt9953cf22012-10-31 01:15:05 +00002
3; This tests correct handling of empty aggregate parameters and return values.
4; An empty parameter passed by value does not consume a protocol register or
5; a parameter save area doubleword. An empty parameter passed by reference
6; is treated as any other pointer parameter. An empty aggregate return value
7; is treated as any other aggregate return value, passed via address as a
8; hidden parameter in GPR3. In this example, GPR3 contains the return value
9; address, GPR4 contains the address of e2, and e1 and e3 are not passed or
10; received.
11
12target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
13target triple = "powerpc64-unknown-linux-gnu"
14
15%struct.empty = type {}
16
17define void @callee(%struct.empty* noalias sret %agg.result, %struct.empty* byval %a1, %struct.empty* %a2, %struct.empty* byval %a3) nounwind {
18entry:
19 %a2.addr = alloca %struct.empty*, align 8
20 store %struct.empty* %a2, %struct.empty** %a2.addr, align 8
David Blaikiea79ac142015-02-27 21:17:42 +000021 %0 = load %struct.empty*, %struct.empty** %a2.addr, align 8
Bill Schmidt9953cf22012-10-31 01:15:05 +000022 %1 = bitcast %struct.empty* %agg.result to i8*
23 %2 = bitcast %struct.empty* %0 to i8*
Daniel Neilson1e687242018-01-19 17:13:12 +000024 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* %2, i64 0, i1 false)
Bill Schmidt9953cf22012-10-31 01:15:05 +000025 ret void
26}
27
Stephen Lind24ab202013-07-14 06:24:09 +000028; CHECK-LABEL: callee:
Bill Schmidt9953cf22012-10-31 01:15:05 +000029; CHECK: std 4,
Bill Schmidt9953cf22012-10-31 01:15:05 +000030; CHECK-NOT: std 5,
31; CHECK-NOT: std 6,
32; CHECK: blr
33
Daniel Neilson1e687242018-01-19 17:13:12 +000034declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind
Bill Schmidt9953cf22012-10-31 01:15:05 +000035
36define void @caller(%struct.empty* noalias sret %agg.result) nounwind {
37entry:
38 %e1 = alloca %struct.empty, align 1
39 %e2 = alloca %struct.empty, align 1
40 %e3 = alloca %struct.empty, align 1
41 call void @callee(%struct.empty* sret %agg.result, %struct.empty* byval %e1, %struct.empty* %e2, %struct.empty* byval %e3)
42 ret void
43}
44
Stephen Lind24ab202013-07-14 06:24:09 +000045; CHECK-LABEL: caller:
Bill Schmidt9953cf22012-10-31 01:15:05 +000046; CHECK: addi 4,
Bill Schmidt9953cf22012-10-31 01:15:05 +000047; CHECK-NOT: std 5,
48; CHECK-NOT: std 6,
49; CHECK: bl callee