|
1 | 1 | // RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,DARWIN
|
2 |
| -// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | FileCheck %s --check-prefixes=CHECK,C |
3 |
| -// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CXX |
| 2 | +// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | FileCheck %s --check-prefixes=CHECK,C,AAPCS |
| 3 | +// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CXX,AAPCS |
4 | 4 |
|
5 | 5 | // Empty structs are ignored for PCS purposes on Darwin and in C mode elsewhere.
|
6 | 6 | // In C++ mode on ELF they consume a register slot though. Functions are
|
@@ -110,3 +110,110 @@ EXTERNC struct SortOfEmpty sort_of_empty_arg_variadic(int a, ...) {
|
110 | 110 | return b;
|
111 | 111 | }
|
112 | 112 |
|
| 113 | +// Base case, nothing interesting. |
| 114 | +struct S { |
| 115 | + long x, y; |
| 116 | +}; |
| 117 | + |
| 118 | +// CHECK-LABEL: @g_S( |
| 119 | +// CHECK: call void @f_S(i64 noundef 1, [2 x i64] {{.*}}) |
| 120 | +// CHECK: call void @fm_S(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, [2 x i64] {{.*}}) |
| 121 | +EXTERNC void f_S(long, struct S); |
| 122 | +EXTERNC void fm_S(long, long, long, long, long, struct S); |
| 123 | +EXTERNC void g_S() { |
| 124 | + struct S s = {6, 7}; |
| 125 | + f_S(1, s); |
| 126 | + fm_S(1, 2, 3, 4, 5, s); |
| 127 | +} |
| 128 | + |
| 129 | +// Aligned struct passed according to its natural alignment. |
| 130 | +struct __attribute__((aligned(16))) S16 { |
| 131 | + long x, y; |
| 132 | +}; |
| 133 | + |
| 134 | +// CHECK-LABEL: @g_S16( |
| 135 | +// DARWIN: call void @f_S16(i64 noundef 1, i128 {{.*}}) |
| 136 | +// AAPCS: call void @f_S16(i64 noundef 1, [2 x i64] {{.*}}) |
| 137 | +// DARWIN: call void @fm_S16(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, i128 {{.*}}) |
| 138 | +// AAPCS: call void @fm_S16(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, [2 x i64] {{.*}}) |
| 139 | +EXTERNC void f_S16(long, struct S16); |
| 140 | +EXTERNC void fm_S16(long, long, long, long, long, struct S16); |
| 141 | +EXTERNC void g_S16() { |
| 142 | + struct S16 s = {6, 7}; |
| 143 | + f_S16(1, s); |
| 144 | + fm_S16(1, 2, 3, 4, 5, s); |
| 145 | +} |
| 146 | + |
| 147 | +// Aligned struct with increased natural alignment through an aligned field. |
| 148 | +struct SF16 { |
| 149 | + __attribute__((aligned(16))) long x; |
| 150 | + long y; |
| 151 | +}; |
| 152 | + |
| 153 | +// CHECK-LABEL: @g_SF16( |
| 154 | +// DARWIN: call void @f_SF16(i64 noundef 1, i128 {{.*}}) |
| 155 | +// AAPCS: call void @f_SF16(i64 noundef 1, i128 {{.*}}) |
| 156 | +// DARWIN: call void @fm_SF16(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, i128 {{.*}}) |
| 157 | +// AAPCS: call void @fm_SF16(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, i128 {{.*}}) |
| 158 | +EXTERNC void f_SF16(long, struct SF16); |
| 159 | +EXTERNC void fm_SF16(long, long, long, long, long, struct SF16); |
| 160 | +EXTERNC void g_SF16() { |
| 161 | + struct SF16 s = {6, 7}; |
| 162 | + f_SF16(1, s); |
| 163 | + fm_SF16(1, 2, 3, 4, 5, s); |
| 164 | +} |
| 165 | + |
| 166 | +#ifdef __cplusplus |
| 167 | +// Aligned struct with increased natural alignment through an aligned base class. |
| 168 | +struct SB16 : S16 {}; |
| 169 | + |
| 170 | +// DARWIN-LABEL: @g_SB16( |
| 171 | +// CXX-LABEL: @g_SB16( |
| 172 | +// DARWIN: call void @f_SB16(i64 noundef 1, i128 {{.*}}) |
| 173 | +// CXX: call void @f_SB16(i64 noundef 1, i128 {{.*}}) |
| 174 | +// DARWIN: call void @fm_SB16(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, i128 {{.*}}) |
| 175 | +// CXX: call void @fm_SB16(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 noundef 4, i64 noundef 5, i128 {{.*}}) |
| 176 | +EXTERNC void f_SB16(long, struct SB16); |
| 177 | +EXTERNC void fm_SB16(long, long, long, long, long, struct SB16); |
| 178 | +EXTERNC void g_SB16() { |
| 179 | + struct SB16 s = {6, 7}; |
| 180 | + f_SB16(1, s); |
| 181 | + fm_SB16(1, 2, 3, 4, 5, s); |
| 182 | +} |
| 183 | +#endif |
| 184 | + |
| 185 | +// Packed structure. |
| 186 | +struct __attribute__((packed)) SP { |
| 187 | + int x; |
| 188 | + long y; |
| 189 | +}; |
| 190 | + |
| 191 | +// CHECK-LABEL: @g_SP( |
| 192 | +// CHECK: call void @f_SP(i32 noundef 1, [2 x i64] {{.*}}) |
| 193 | +// CHECK: call void @fm_SP(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, [2 x i64] {{.*}}) |
| 194 | +EXTERNC void f_SP(int, struct SP); |
| 195 | +EXTERNC void fm_SP(int, int, int, int, int, struct SP); |
| 196 | +EXTERNC void g_SP() { |
| 197 | + struct SP s = {6, 7}; |
| 198 | + f_SP(1, s); |
| 199 | + fm_SP(1, 2, 3, 4, 5, s); |
| 200 | +} |
| 201 | + |
| 202 | +// Packed structure, overaligned, same as above. |
| 203 | +struct __attribute__((packed, aligned(16))) SP16 { |
| 204 | + int x; |
| 205 | + long y; |
| 206 | +}; |
| 207 | + |
| 208 | +// CHECK-LABEL: @g_SP16( |
| 209 | +// DARWIN: call void @f_SP16(i32 noundef 1, i128 {{.*}}) |
| 210 | +// AAPCS: call void @f_SP16(i32 noundef 1, [2 x i64] {{.*}}) |
| 211 | +// DARWIN: call void @fm_SP16(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, i128 {{.*}}) |
| 212 | +// AAPCS: call void @fm_SP16(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 4, i32 noundef 5, [2 x i64] {{.*}}) |
| 213 | +EXTERNC void f_SP16(int, struct SP16); |
| 214 | +EXTERNC void fm_SP16(int, int, int, int, int, struct SP16); |
| 215 | +EXTERNC void g_SP16() { |
| 216 | + struct SP16 s = {6, 7}; |
| 217 | + f_SP16(1, s); |
| 218 | + fm_SP16(1, 2, 3, 4, 5, s); |
| 219 | +} |
0 commit comments