| 1 |
// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s --check-prefix=X86-64 |
| 3 |
// RUN: %clang_cc1 -no-enable-noundef-analysis -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s |
| 4 |
// RUN: %clang_cc1 -no-enable-noundef-analysis -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64 |
| 5 |
|
| 6 |
// REQUIRES: aarch64-registered-target,x86-registered-target |
| 7 |
|
| 8 |
#define SWIFTCALL __attribute__((swiftcall)) |
| 9 |
#define SWIFTASYNCCALL __attribute__((swiftasynccall)) |
| 10 |
#define OUT __attribute__((swift_indirect_result)) |
| 11 |
#define ERROR __attribute__((swift_error_result)) |
| 12 |
#define CONTEXT __attribute__((swift_context)) |
| 13 |
#define ASYNC_CONTEXT __attribute__((swift_async_context)) |
| 14 |
|
| 15 |
// CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } } |
| 16 |
// CHECK-DAG: %struct.packed = type <{ i64, i8 }> |
| 17 |
|
| 18 |
/*****************************************************************************/ |
| 19 |
/****************************** PARAMETER ABIS *******************************/ |
| 20 |
/*****************************************************************************/ |
| 21 |
|
| 22 |
SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {} |
| 23 |
// CHECK-LABEL: define {{.*}} void @indirect_result_1(ptr noalias sret(ptr) align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}}) |
| 24 |
|
| 25 |
// TODO: maybe this shouldn't suppress sret. |
| 26 |
SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } |
| 27 |
// CHECK-LABEL: define {{.*}} i32 @indirect_result_2(ptr noalias align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}}) |
| 28 |
|
| 29 |
typedef struct { char array[1024]; } struct_reallybig; |
| 30 |
SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } |
| 31 |
// CHECK-LABEL: define {{.*}} void @indirect_result_3(ptr dead_on_unwind noalias writable sret(%struct.struct_reallybig) {{.*}}, ptr noalias align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}}) |
| 32 |
|
| 33 |
SWIFTCALL void context_1(CONTEXT void *self) {} |
| 34 |
// CHECK-LABEL: define {{.*}} void @context_1(ptr swiftself |
| 35 |
|
| 36 |
SWIFTASYNCCALL void async_context_1(ASYNC_CONTEXT void *ctx) {} |
| 37 |
// CHECK-LABEL: define {{.*}} void @async_context_1(ptr swiftasync |
| 38 |
|
| 39 |
SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {} |
| 40 |
// CHECK-LABEL: define {{.*}} void @context_2(ptr{{.*}}, ptr swiftself |
| 41 |
|
| 42 |
SWIFTASYNCCALL void async_context_2(void *arg0, ASYNC_CONTEXT void *ctx) {} |
| 43 |
// CHECK-LABEL: define {{.*}} void @async_context_2(ptr{{.*}}, ptr swiftasync |
| 44 |
|
| 45 |
SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {} |
| 46 |
// CHECK-LABEL: define {{.*}} void @context_error_1(ptr swiftself{{.*}}, ptr swifterror %0) |
| 47 |
// CHECK: [[TEMP:%.*]] = alloca ptr, align 8 |
| 48 |
// CHECK: [[T0:%.*]] = load ptr, ptr [[ERRORARG:%.*]], align 8 |
| 49 |
// CHECK: store ptr [[T0]], ptr [[TEMP]], align 8 |
| 50 |
// CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 8 |
| 51 |
// CHECK: store ptr [[T0]], ptr [[ERRORARG]], align 8 |
| 52 |
void test_context_error_1() { |
| 53 |
int x; |
| 54 |
float *error; |
| 55 |
context_error_1(&x, &error); |
| 56 |
} |
| 57 |
// CHECK-LABEL: define{{.*}} void @test_context_error_1() |
| 58 |
// CHECK: [[X:%.*]] = alloca i32, align 4 |
| 59 |
// CHECK: [[ERROR:%.*]] = alloca ptr, align 8 |
| 60 |
// CHECK: [[TEMP:%.*]] = alloca swifterror ptr, align 8 |
| 61 |
// CHECK: [[T0:%.*]] = load ptr, ptr [[ERROR]], align 8 |
| 62 |
// CHECK: store ptr [[T0]], ptr [[TEMP]], align 8 |
| 63 |
// CHECK: call [[SWIFTCC:swiftcc]] void @context_error_1(ptr swiftself [[X]], ptr swifterror [[TEMP]]) |
| 64 |
// CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 8 |
| 65 |
// CHECK: store ptr [[T0]], ptr [[ERROR]], align 8 |
| 66 |
|
| 67 |
SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float **error) {} |
| 68 |
// CHECK-LABEL: define {{.*}} void @context_error_2(i16{{.*}}, ptr swiftself{{.*}}, ptr swifterror %0) |
| 69 |
|
| 70 |
/*****************************************************************************/ |
| 71 |
/********************************** LOWERING *********************************/ |
| 72 |
/*****************************************************************************/ |
| 73 |
|
| 74 |
typedef float float3 __attribute__((ext_vector_type(3))); |
| 75 |
typedef float float4 __attribute__((ext_vector_type(4))); |
| 76 |
typedef float float8 __attribute__((ext_vector_type(8))); |
| 77 |
typedef double double2 __attribute__((ext_vector_type(2))); |
| 78 |
typedef double double4 __attribute__((ext_vector_type(4))); |
| 79 |
typedef int int3 __attribute__((ext_vector_type(3))); |
| 80 |
typedef int int4 __attribute__((ext_vector_type(4))); |
| 81 |
typedef int int5 __attribute__((ext_vector_type(5))); |
| 82 |
typedef int int8 __attribute__((ext_vector_type(8))); |
| 83 |
typedef char char16 __attribute__((ext_vector_type(16))); |
| 84 |
typedef short short8 __attribute__((ext_vector_type(8))); |
| 85 |
typedef long long long2 __attribute__((ext_vector_type(2))); |
| 86 |
|
| 87 |
#define TEST(TYPE) \ |
| 88 |
SWIFTCALL TYPE return_##TYPE(void) { \ |
| 89 |
TYPE result = {}; \ |
| 90 |
return result; \ |
| 91 |
} \ |
| 92 |
SWIFTCALL void take_##TYPE(TYPE v) { \ |
| 93 |
} \ |
| 94 |
void test_##TYPE() { \ |
| 95 |
take_##TYPE(return_##TYPE()); \ |
| 96 |
} |
| 97 |
|
| 98 |
/*****************************************************************************/ |
| 99 |
/*********************************** STRUCTS *********************************/ |
| 100 |
/*****************************************************************************/ |
| 101 |
|
| 102 |
typedef struct { |
| 103 |
} struct_empty; |
| 104 |
TEST(struct_empty); |
| 105 |
// CHECK-LABEL: define {{.*}} @return_struct_empty() |
| 106 |
// CHECK: ret void |
| 107 |
// CHECK-LABEL: define {{.*}} @take_struct_empty() |
| 108 |
// CHECK: ret void |
| 109 |
|
| 110 |
typedef struct { |
| 111 |
int x; |
| 112 |
char c0; |
| 113 |
char c1; |
| 114 |
int f0; |
| 115 |
int f1; |
| 116 |
} struct_1; |
| 117 |
TEST(struct_1); |
| 118 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_1() {{.*}}{ |
| 119 |
// CHECK: [[RET:%.*]] = alloca [[STRUCT1:%.*]], align 4 |
| 120 |
// CHECK: call void @llvm.memset |
| 121 |
// CHECK: [[GEP0:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr %retval, i32 0, i32 0 |
| 122 |
// CHECK: [[T0:%.*]] = load i64, ptr [[GEP0]], align 4 |
| 123 |
// CHECK: [[GEP1:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr %retval, i32 0, i32 1 |
| 124 |
// CHECK: [[T1:%.*]] = load i64, ptr [[GEP1]], align 4 |
| 125 |
// CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0 |
| 126 |
// CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1 |
| 127 |
// CHECK: ret { i64, i64 } [[R1]] |
| 128 |
// CHECK: } |
| 129 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_1(i64 %0, i64 %1) {{.*}}{ |
| 130 |
// CHECK: [[V:%.*]] = alloca [[STRUCT1:%.*]], align 4 |
| 131 |
// CHECK: [[GEP0:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[V]], i32 0, i32 0 |
| 132 |
// CHECK: store i64 %0, ptr [[GEP0]], align 4 |
| 133 |
// CHECK: [[GEP1:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[V]], i32 0, i32 1 |
| 134 |
// CHECK: store i64 %1, ptr [[GEP1]], align 4 |
| 135 |
// CHECK: ret void |
| 136 |
// CHECK: } |
| 137 |
// CHECK-LABEL: define{{.*}} void @test_struct_1() {{.*}}{ |
| 138 |
// CHECK: [[AGG:%.*]] = alloca [[STRUCT1:%.*]], align 4 |
| 139 |
// CHECK: [[RET:%.*]] = call swiftcc { i64, i64 } @return_struct_1() |
| 140 |
// CHECK: [[GEP0:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[AGG]], i32 0, i32 0 |
| 141 |
// CHECK: [[E0:%.*]] = extractvalue { i64, i64 } [[RET]], 0 |
| 142 |
// CHECK: store i64 [[E0]], ptr [[GEP0]], align 4 |
| 143 |
// CHECK: [[GEP1:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[AGG]], i32 0, i32 1 |
| 144 |
// CHECK: [[E1:%.*]] = extractvalue { i64, i64 } [[RET]], 1 |
| 145 |
// CHECK: store i64 [[E1]], ptr [[GEP1]], align 4 |
| 146 |
// CHECK: [[GEP2:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[AGG]], i32 0, i32 0 |
| 147 |
// CHECK: [[V0:%.*]] = load i64, ptr [[GEP2]], align 4 |
| 148 |
// CHECK: [[GEP3:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[AGG]], i32 0, i32 1 |
| 149 |
// CHECK: [[V1:%.*]] = load i64, ptr [[GEP3]], align 4 |
| 150 |
// CHECK: call swiftcc void @take_struct_1(i64 [[V0]], i64 [[V1]]) |
| 151 |
// CHECK: ret void |
| 152 |
// CHECK: } |
| 153 |
|
| 154 |
typedef struct { |
| 155 |
int x; |
| 156 |
char c0; |
| 157 |
__attribute__((aligned(2))) char c1; |
| 158 |
int f0; |
| 159 |
int f1; |
| 160 |
} struct_2; |
| 161 |
TEST(struct_2); |
| 162 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_2() {{.*}}{ |
| 163 |
// CHECK: [[RET:%.*]] = alloca [[STRUCT2:%.*]], align 4 |
| 164 |
// CHECK: call void @llvm.memset |
| 165 |
// CHECK: [[GEP0:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[RET]], i32 0, i32 0 |
| 166 |
// CHECK: [[T0:%.*]] = load i64, ptr [[GEP0]], align 4 |
| 167 |
// CHECK: [[GEP1:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[RET]], i32 0, i32 1 |
| 168 |
// CHECK: [[T1:%.*]] = load i64, ptr [[GEP1]], align 4 |
| 169 |
// CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0 |
| 170 |
// CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1 |
| 171 |
// CHECK: ret { i64, i64 } [[R1]] |
| 172 |
// CHECK: } |
| 173 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_2(i64 %0, i64 %1) {{.*}}{ |
| 174 |
// CHECK: [[V:%.*]] = alloca [[STRUCT2]], align 4 |
| 175 |
// CHECK: [[GEP0:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[V]], i32 0, i32 0 |
| 176 |
// CHECK: store i64 %0, ptr [[GEP0]], align 4 |
| 177 |
// CHECK: [[GEP1:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[V]], i32 0, i32 1 |
| 178 |
// CHECK: store i64 %1, ptr [[GEP1]], align 4 |
| 179 |
// CHECK: ret void |
| 180 |
// CHECK: } |
| 181 |
// CHECK-LABEL: define{{.*}} void @test_struct_2() {{.*}} { |
| 182 |
// CHECK: [[TMP:%.*]] = alloca [[STRUCT2]], align 4 |
| 183 |
// CHECK: [[CALL:%.*]] = call swiftcc { i64, i64 } @return_struct_2() |
| 184 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw {{.*}} [[TMP]], i32 0, i32 0 |
| 185 |
// CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 0 |
| 186 |
// CHECK: store i64 [[T0]], ptr [[GEP]], align 4 |
| 187 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw {{.*}} [[TMP]], i32 0, i32 1 |
| 188 |
// CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 1 |
| 189 |
// CHECK: store i64 [[T0]], ptr [[GEP]], align 4 |
| 190 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[TMP]], i32 0, i32 0 |
| 191 |
// CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 4 |
| 192 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw { i64, i64 }, ptr [[TMP]], i32 0, i32 1 |
| 193 |
// CHECK: [[R1:%.*]] = load i64, ptr [[GEP]], align 4 |
| 194 |
// CHECK: call swiftcc void @take_struct_2(i64 [[R0]], i64 [[R1]]) |
| 195 |
// CHECK: ret void |
| 196 |
// CHECK: } |
| 197 |
|
| 198 |
// There's no way to put a field randomly in the middle of an otherwise |
| 199 |
// empty storage unit in C, so that case has to be tested in C++, which |
| 200 |
// can use empty structs to introduce arbitrary padding. (In C, they end up |
| 201 |
// with size 0 and so don't affect layout.) |
| 202 |
|
| 203 |
// Misaligned data rule. |
| 204 |
typedef struct { |
| 205 |
char c0; |
| 206 |
__attribute__((packed)) float f; |
| 207 |
} struct_misaligned_1; |
| 208 |
TEST(struct_misaligned_1) |
| 209 |
// CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_misaligned_1() |
| 210 |
// CHECK: [[RET:%.*]] = alloca [[STRUCT:%.*]], align 1 |
| 211 |
// CHECK: call void @llvm.memset{{.*}}(ptr align 1 [[RET]], i8 0, i64 5 |
| 212 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[RET]], i32 0, i32 0 |
| 213 |
// CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 1 |
| 214 |
// CHECK: ret i64 [[R0]] |
| 215 |
// CHECK:} |
| 216 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_misaligned_1(i64 %0) {{.*}}{ |
| 217 |
// CHECK: [[V:%.*]] = alloca [[STRUCT:%.*]], align 1 |
| 218 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[V]], i32 0, i32 0 |
| 219 |
// CHECK: store i64 %0, ptr [[GEP]], align 1 |
| 220 |
// CHECK: ret void |
| 221 |
// CHECK: } |
| 222 |
// CHECK: define{{.*}} void @test_struct_misaligned_1() {{.*}}{ |
| 223 |
// CHECK: [[AGG:%.*]] = alloca [[STRUCT:%.*]], align 1 |
| 224 |
// CHECK: [[CALL:%.*]] = call swiftcc i64 @return_struct_misaligned_1() |
| 225 |
// CHECK: [[T1:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[AGG]], i32 0, i32 0 |
| 226 |
// CHECK: store i64 [[CALL]], ptr [[T1]], align 1 |
| 227 |
// CHECK: [[T1:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[AGG]], i32 0, i32 0 |
| 228 |
// CHECK: [[P:%.*]] = load i64, ptr [[T1]], align 1 |
| 229 |
// CHECK: call swiftcc void @take_struct_misaligned_1(i64 [[P]]) |
| 230 |
// CHECK: ret void |
| 231 |
// CHECK: } |
| 232 |
|
| 233 |
// Too many scalars. |
| 234 |
typedef struct { |
| 235 |
long long x[5]; |
| 236 |
} struct_big_1; |
| 237 |
TEST(struct_big_1) |
| 238 |
|
| 239 |
// CHECK-LABEL: define {{.*}} void @return_struct_big_1(ptr dead_on_unwind noalias writable sret |
| 240 |
|
| 241 |
// Should not be byval. |
| 242 |
// CHECK-LABEL: define {{.*}} void @take_struct_big_1(ptr dead_on_return{{( %.*)?}}) |
| 243 |
|
| 244 |
/*****************************************************************************/ |
| 245 |
/********************************* TYPE MERGING ******************************/ |
| 246 |
/*****************************************************************************/ |
| 247 |
|
| 248 |
typedef union { |
| 249 |
float f; |
| 250 |
double d; |
| 251 |
} union_het_fp; |
| 252 |
TEST(union_het_fp) |
| 253 |
// CHECK-LABEL: define{{.*}} swiftcc i64 @return_union_het_fp() |
| 254 |
// CHECK: [[RET:%.*]] = alloca [[UNION:%.*]], align 8 |
| 255 |
// CHECK: call void @llvm.memset{{.*}}(ptr align 8 [[RET]] |
| 256 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[RET]], i32 0, i32 0 |
| 257 |
// CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 8 |
| 258 |
// CHECK: ret i64 [[R0]] |
| 259 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_union_het_fp(i64 %0) {{.*}}{ |
| 260 |
// CHECK: [[V:%.*]] = alloca [[UNION:%.*]], align 8 |
| 261 |
// CHECK: [[GEP:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[V]], i32 0, i32 0 |
| 262 |
// CHECK: store i64 %0, ptr [[GEP]], align 8 |
| 263 |
// CHECK: ret void |
| 264 |
// CHECK: } |
| 265 |
// CHECK-LABEL: define{{.*}} void @test_union_het_fp() {{.*}}{ |
| 266 |
// CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 8 |
| 267 |
// CHECK: [[CALL:%.*]] = call swiftcc i64 @return_union_het_fp() |
| 268 |
// CHECK: [[T1:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[AGG]], i32 0, i32 0 |
| 269 |
// CHECK: store i64 [[CALL]], ptr [[T1]], align 8 |
| 270 |
// CHECK: [[T1:%.*]] = getelementptr inbounds nuw { i64 }, ptr [[AGG]], i32 0, i32 0 |
| 271 |
// CHECK: [[V0:%.*]] = load i64, ptr [[T1]], align 8 |
| 272 |
// CHECK: call swiftcc void @take_union_het_fp(i64 [[V0]]) |
| 273 |
// CHECK: ret void |
| 274 |
// CHECK: } |
| 275 |
|
| 276 |
|
| 277 |
typedef union { |
| 278 |
float f1; |
| 279 |
float f2; |
| 280 |
} union_hom_fp; |
| 281 |
TEST(union_hom_fp) |
| 282 |
// CHECK-LABEL: define{{.*}} void @test_union_hom_fp() |
| 283 |
// CHECK: [[TMP:%.*]] = alloca [[REC:%.*]], align 4 |
| 284 |
// CHECK: [[CALL:%.*]] = call [[SWIFTCC]] float @return_union_hom_fp() |
| 285 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float }, ptr [[TMP]], i32 0, i32 0 |
| 286 |
// CHECK: store float [[CALL]], ptr [[T0]], align 4 |
| 287 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float }, ptr [[TMP]], i32 0, i32 0 |
| 288 |
// CHECK: [[FIRST:%.*]] = load float, ptr [[T0]], align 4 |
| 289 |
// CHECK: call [[SWIFTCC]] void @take_union_hom_fp(float [[FIRST]]) |
| 290 |
// CHECK: ret void |
| 291 |
|
| 292 |
typedef union { |
| 293 |
float f1; |
| 294 |
float4 fv2; |
| 295 |
} union_hom_fp_partial; |
| 296 |
TEST(union_hom_fp_partial) |
| 297 |
// CHECK: define{{.*}} void @test_union_hom_fp_partial() |
| 298 |
// CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16 |
| 299 |
// CHECK: [[CALL:%.*]] = call swiftcc { float, float, float, float } @return_union_hom_fp_partial() |
| 300 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 0 |
| 301 |
// CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 0 |
| 302 |
// CHECK: store float [[T1]], ptr [[T0]], align 16 |
| 303 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 1 |
| 304 |
// CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 1 |
| 305 |
// CHECK: store float [[T1]], ptr [[T0]], align 4 |
| 306 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 2 |
| 307 |
// CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 2 |
| 308 |
// CHECK: store float [[T1]], ptr [[T0]], align 8 |
| 309 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 3 |
| 310 |
// CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 3 |
| 311 |
// CHECK: store float [[T1]], ptr [[T0]], align 4 |
| 312 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 0 |
| 313 |
// CHECK: [[V0:%.*]] = load float, ptr [[T0]], align 16 |
| 314 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 1 |
| 315 |
// CHECK: [[V1:%.*]] = load float, ptr [[T0]], align 4 |
| 316 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 2 |
| 317 |
// CHECK: [[V2:%.*]] = load float, ptr [[T0]], align 8 |
| 318 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { float, float, float, float }, ptr [[AGG]], i32 0, i32 3 |
| 319 |
// CHECK: [[V3:%.*]] = load float, ptr [[T0]], align 4 |
| 320 |
// CHECK: call swiftcc void @take_union_hom_fp_partial(float [[V0]], float [[V1]], float [[V2]], float [[V3]]) |
| 321 |
// CHECK: ret void |
| 322 |
// CHECK: } |
| 323 |
|
| 324 |
typedef union { |
| 325 |
struct { int x, y; } f1; |
| 326 |
float4 fv2; |
| 327 |
} union_het_fpv_partial; |
| 328 |
TEST(union_het_fpv_partial) |
| 329 |
// CHECK-LABEL: define{{.*}} void @test_union_het_fpv_partial() |
| 330 |
// CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16 |
| 331 |
// CHECK: [[CALL:%.*]] = call swiftcc { i64, float, float } @return_union_het_fpv_partial() |
| 332 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { i64, float, float }, ptr [[AGG]], i32 0, i32 0 |
| 333 |
// CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 0 |
| 334 |
// CHECK: store i64 [[T1]], ptr [[T0]], align 16 |
| 335 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { i64, float, float }, ptr [[AGG]], i32 0, i32 1 |
| 336 |
// CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 1 |
| 337 |
// CHECK: store float [[T1]], ptr [[T0]], align 8 |
| 338 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { i64, float, float }, ptr [[AGG]], i32 0, i32 2 |
| 339 |
// CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 2 |
| 340 |
// CHECK: store float [[T1]], ptr [[T0]], align 4 |
| 341 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { i64, float, float }, ptr [[AGG]], i32 0, i32 0 |
| 342 |
// CHECK: [[V0:%.*]] = load i64, ptr [[T0]], align 16 |
| 343 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { i64, float, float }, ptr [[AGG]], i32 0, i32 1 |
| 344 |
// CHECK: [[V1:%.*]] = load float, ptr [[T0]], align 8 |
| 345 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw { i64, float, float }, ptr [[AGG]], i32 0, i32 2 |
| 346 |
// CHECK: [[V2:%.*]] = load float, ptr [[T0]], align 4 |
| 347 |
// CHECK: call swiftcc void @take_union_het_fpv_partial(i64 [[V0]], float [[V1]], float [[V2]]) |
| 348 |
// CHECK: ret void |
| 349 |
// CHECK: } |
| 350 |
|
| 351 |
/*****************************************************************************/ |
| 352 |
/****************************** VECTOR LEGALIZATION **************************/ |
| 353 |
/*****************************************************************************/ |
| 354 |
|
| 355 |
TEST(int4) |
| 356 |
// CHECK-LABEL: define {{.*}} <4 x i32> @return_int4() |
| 357 |
// CHECK-LABEL: define {{.*}} @take_int4(<4 x i32> |
| 358 |
|
| 359 |
TEST(int8) |
| 360 |
// CHECK-LABEL: define {{.*}} @return_int8() |
| 361 |
// CHECK: [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 16 |
| 362 |
// CHECK: [[VAR:%.*]] = alloca [[REC]], align |
| 363 |
// CHECK: store |
| 364 |
// CHECK: load |
| 365 |
// CHECK: store |
| 366 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:.+]], ptr [[RET]], i32 0, i32 0 |
| 367 |
// CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align |
| 368 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1 |
| 369 |
// CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align |
| 370 |
// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, <4 x i32> [[FIRST]], 0 |
| 371 |
// CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1 |
| 372 |
// CHECK: ret [[UAGG]] [[T1]] |
| 373 |
// CHECK-LABEL: define {{.*}} @take_int8(<4 x i32> %0, <4 x i32> %1) |
| 374 |
// CHECK: [[V:%.*]] = alloca [[REC]], align |
| 375 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0 |
| 376 |
// CHECK: store <4 x i32> %0, ptr [[T0]], align |
| 377 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1 |
| 378 |
// CHECK: store <4 x i32> %1, ptr [[T0]], align |
| 379 |
// CHECK: ret void |
| 380 |
// CHECK-LABEL: define{{.*}} void @test_int8() |
| 381 |
// CHECK: [[TMP1:%.*]] = alloca [[REC]], align |
| 382 |
// CHECK: [[TMP2:%.*]] = alloca [[REC]], align |
| 383 |
// CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int8() |
| 384 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 0 |
| 385 |
// CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0 |
| 386 |
// CHECK: store <4 x i32> [[T1]], ptr [[T0]], align |
| 387 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 1 |
| 388 |
// CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1 |
| 389 |
// CHECK: store <4 x i32> [[T1]], ptr [[T0]], align |
| 390 |
// CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align |
| 391 |
// CHECK: store [[REC]] [[V]], ptr [[TMP2]], align |
| 392 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 0 |
| 393 |
// CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align |
| 394 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 1 |
| 395 |
// CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align |
| 396 |
// CHECK: call [[SWIFTCC]] void @take_int8(<4 x i32> [[FIRST]], <4 x i32> [[SECOND]]) |
| 397 |
// CHECK: ret void |
| 398 |
|
| 399 |
TEST(int5) |
| 400 |
// CHECK-LABEL: define {{.*}} @return_int5() |
| 401 |
// CHECK: [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 16 |
| 402 |
// CHECK: [[VAR:%.*]] = alloca [[REC]], align |
| 403 |
// CHECK: store |
| 404 |
// CHECK: load |
| 405 |
// CHECK: store |
| 406 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:.+]], ptr [[RET]], i32 0, i32 0 |
| 407 |
// CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align |
| 408 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1 |
| 409 |
// CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align |
| 410 |
// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x i32> [[FIRST]], 0 |
| 411 |
// CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1 |
| 412 |
// CHECK: ret [[UAGG]] [[T1]] |
| 413 |
// CHECK-LABEL: define {{.*}} @take_int5(<4 x i32> %0, i32 %1) |
| 414 |
// CHECK: [[V:%.*]] = alloca [[REC]], align |
| 415 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0 |
| 416 |
// CHECK: store <4 x i32> %0, ptr [[T0]], align |
| 417 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1 |
| 418 |
// CHECK: store i32 %1, ptr [[T0]], align |
| 419 |
// CHECK: ret void |
| 420 |
// CHECK-LABEL: define{{.*}} void @test_int5() |
| 421 |
// CHECK: [[TMP1:%.*]] = alloca [[REC]], align |
| 422 |
// CHECK: [[TMP2:%.*]] = alloca [[REC]], align |
| 423 |
// CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int5() |
| 424 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 0 |
| 425 |
// CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0 |
| 426 |
// CHECK: store <4 x i32> [[T1]], ptr [[T0]], align |
| 427 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 1 |
| 428 |
// CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1 |
| 429 |
// CHECK: store i32 [[T1]], ptr [[T0]], align |
| 430 |
// CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align |
| 431 |
// CHECK: store [[REC]] [[V]], ptr [[TMP2]], align |
| 432 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 0 |
| 433 |
// CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align |
| 434 |
// CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 1 |
| 435 |
// CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align |
| 436 |
// CHECK: call [[SWIFTCC]] void @take_int5(<4 x i32> [[FIRST]], i32 [[SECOND]]) |
| 437 |
// CHECK: ret void |
| 438 |
|
| 439 |
typedef struct { |
| 440 |
int x; |
| 441 |
int3 v __attribute__((packed)); |
| 442 |
} misaligned_int3; |
| 443 |
TEST(misaligned_int3) |
| 444 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_misaligned_int3(i64 %0, i64 %1) |
| 445 |
|
| 446 |
typedef struct { |
| 447 |
float f0; |
| 448 |
} struct_f1; |
| 449 |
TEST(struct_f1) |
| 450 |
// CHECK-LABEL: define{{.*}} swiftcc float @return_struct_f1() |
| 451 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f1(float %0) |
| 452 |
|
| 453 |
typedef struct { |
| 454 |
float f0; |
| 455 |
float f1; |
| 456 |
} struct_f2; |
| 457 |
TEST(struct_f2) |
| 458 |
// CHECK-LABEL: define{{.*}} swiftcc { float, float } @return_struct_f2() |
| 459 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f2(float %0, float %1) |
| 460 |
|
| 461 |
typedef struct { |
| 462 |
float f0; |
| 463 |
float f1; |
| 464 |
float f2; |
| 465 |
} struct_f3; |
| 466 |
TEST(struct_f3) |
| 467 |
// CHECK-LABEL: define{{.*}} swiftcc { float, float, float } @return_struct_f3() |
| 468 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f3(float %0, float %1, float %2) |
| 469 |
|
| 470 |
typedef struct { |
| 471 |
float f0; |
| 472 |
float f1; |
| 473 |
float f2; |
| 474 |
float f3; |
| 475 |
} struct_f4; |
| 476 |
TEST(struct_f4) |
| 477 |
// CHECK-LABEL: define{{.*}} swiftcc { float, float, float, float } @return_struct_f4() |
| 478 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f4(float %0, float %1, float %2, float %3) |
| 479 |
|
| 480 |
|
| 481 |
typedef struct { |
| 482 |
double d0; |
| 483 |
} struct_d1; |
| 484 |
TEST(struct_d1) |
| 485 |
// CHECK-LABEL: define{{.*}} swiftcc double @return_struct_d1() |
| 486 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d1(double %0) |
| 487 |
|
| 488 |
typedef struct { |
| 489 |
double d0; |
| 490 |
double d1; |
| 491 |
} struct_d2; |
| 492 |
TEST(struct_d2) |
| 493 |
|
| 494 |
// CHECK-LABEL: define{{.*}} swiftcc { double, double } @return_struct_d2() |
| 495 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d2(double %0, double %1) |
| 496 |
typedef struct { |
| 497 |
double d0; |
| 498 |
double d1; |
| 499 |
double d2; |
| 500 |
} struct_d3; |
| 501 |
TEST(struct_d3) |
| 502 |
// CHECK-LABEL: define{{.*}} swiftcc { double, double, double } @return_struct_d3() |
| 503 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d3(double %0, double %1, double %2) |
| 504 |
|
| 505 |
typedef struct { |
| 506 |
double d0; |
| 507 |
double d1; |
| 508 |
double d2; |
| 509 |
double d3; |
| 510 |
} struct_d4; |
| 511 |
TEST(struct_d4) |
| 512 |
// CHECK-LABEL: define{{.*}} swiftcc { double, double, double, double } @return_struct_d4() |
| 513 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d4(double %0, double %1, double %2, double %3) |
| 514 |
|
| 515 |
typedef struct { |
| 516 |
double d0; |
| 517 |
double d1; |
| 518 |
double d2; |
| 519 |
double d3; |
| 520 |
double d4; |
| 521 |
} struct_d5; |
| 522 |
TEST(struct_d5) |
| 523 |
// CHECK: define{{.*}} swiftcc void @return_struct_d5(ptr dead_on_unwind noalias writable sret([[STRUCT5:.+]]) |
| 524 |
// CHECK: define{{.*}} swiftcc void @take_struct_d5(ptr |
| 525 |
|
| 526 |
typedef struct { |
| 527 |
char c0; |
| 528 |
} struct_c1; |
| 529 |
TEST(struct_c1) |
| 530 |
// CHECK-LABEL: define{{.*}} swiftcc i8 @return_struct_c1() |
| 531 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c1(i8 %0) |
| 532 |
|
| 533 |
typedef struct { |
| 534 |
char c0; |
| 535 |
char c1; |
| 536 |
} struct_c2; |
| 537 |
TEST(struct_c2) |
| 538 |
// CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_c2() |
| 539 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c2(i16 %0) |
| 540 |
// |
| 541 |
|
| 542 |
typedef struct { |
| 543 |
char c0; |
| 544 |
char c1; |
| 545 |
char c2; |
| 546 |
} struct_c3; |
| 547 |
TEST(struct_c3) |
| 548 |
// CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c3() |
| 549 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c3(i32 %0) |
| 550 |
|
| 551 |
typedef struct { |
| 552 |
char c0; |
| 553 |
char c1; |
| 554 |
char c2; |
| 555 |
char c3; |
| 556 |
} struct_c4; |
| 557 |
TEST(struct_c4) |
| 558 |
// CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c4() |
| 559 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c4(i32 %0) |
| 560 |
|
| 561 |
typedef struct { |
| 562 |
char c0; |
| 563 |
char c1; |
| 564 |
char c2; |
| 565 |
char c3; |
| 566 |
char c4; |
| 567 |
} struct_c5; |
| 568 |
TEST(struct_c5) |
| 569 |
// CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_c5() |
| 570 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c5(i64 %0) |
| 571 |
// |
| 572 |
typedef struct { |
| 573 |
char c0; |
| 574 |
char c1; |
| 575 |
char c2; |
| 576 |
char c3; |
| 577 |
char c4; |
| 578 |
char c5; |
| 579 |
char c6; |
| 580 |
char c7; |
| 581 |
char c8; |
| 582 |
} struct_c9; |
| 583 |
TEST(struct_c9) |
| 584 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i8 } @return_struct_c9() |
| 585 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c9(i64 %0, i8 %1) |
| 586 |
|
| 587 |
typedef struct { |
| 588 |
short s0; |
| 589 |
} struct_s1; |
| 590 |
TEST(struct_s1) |
| 591 |
// CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_s1() |
| 592 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s1(i16 %0) |
| 593 |
|
| 594 |
typedef struct { |
| 595 |
short s0; |
| 596 |
short s1; |
| 597 |
} struct_s2; |
| 598 |
TEST(struct_s2) |
| 599 |
// CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_s2() |
| 600 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s2(i32 %0) |
| 601 |
// |
| 602 |
|
| 603 |
typedef struct { |
| 604 |
short s0; |
| 605 |
short s1; |
| 606 |
short s2; |
| 607 |
} struct_s3; |
| 608 |
TEST(struct_s3) |
| 609 |
// CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_s3() |
| 610 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s3(i64 %0) |
| 611 |
|
| 612 |
typedef struct { |
| 613 |
short s0; |
| 614 |
short s1; |
| 615 |
short s2; |
| 616 |
short s3; |
| 617 |
} struct_s4; |
| 618 |
TEST(struct_s4) |
| 619 |
// CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_s4() |
| 620 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s4(i64 %0) |
| 621 |
|
| 622 |
typedef struct { |
| 623 |
short s0; |
| 624 |
short s1; |
| 625 |
short s2; |
| 626 |
short s3; |
| 627 |
short s4; |
| 628 |
} struct_s5; |
| 629 |
TEST(struct_s5) |
| 630 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i16 } @return_struct_s5() |
| 631 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s5(i64 %0, i16 %1) |
| 632 |
|
| 633 |
|
| 634 |
typedef struct { |
| 635 |
int i0; |
| 636 |
} struct_i1; |
| 637 |
TEST(struct_i1) |
| 638 |
// CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_i1() |
| 639 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i1(i32 %0) |
| 640 |
|
| 641 |
typedef struct { |
| 642 |
int i0; |
| 643 |
int i1; |
| 644 |
} struct_i2; |
| 645 |
TEST(struct_i2) |
| 646 |
// CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_i2() |
| 647 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i2(i64 %0) |
| 648 |
|
| 649 |
typedef struct { |
| 650 |
int i0; |
| 651 |
int i1; |
| 652 |
int i2; |
| 653 |
} struct_i3; |
| 654 |
TEST(struct_i3) |
| 655 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i32 } @return_struct_i3() |
| 656 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i3(i64 %0, i32 %1) |
| 657 |
|
| 658 |
typedef struct { |
| 659 |
int i0; |
| 660 |
int i1; |
| 661 |
int i2; |
| 662 |
int i3; |
| 663 |
} struct_i4; |
| 664 |
TEST(struct_i4) |
| 665 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_i4() |
| 666 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i4(i64 %0, i64 %1) |
| 667 |
|
| 668 |
typedef struct { |
| 669 |
long long l0; |
| 670 |
} struct_l1; |
| 671 |
TEST(struct_l1) |
| 672 |
// CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_l1() |
| 673 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l1(i64 %0) |
| 674 |
|
| 675 |
typedef struct { |
| 676 |
long long l0; |
| 677 |
long long l1; |
| 678 |
} struct_l2; |
| 679 |
TEST(struct_l2) |
| 680 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_l2() |
| 681 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l2(i64 %0, i64 %1) |
| 682 |
|
| 683 |
typedef struct { |
| 684 |
long long l0; |
| 685 |
long long l1; |
| 686 |
long long l2; |
| 687 |
} struct_l3; |
| 688 |
TEST(struct_l3) |
| 689 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i64, i64 } @return_struct_l3() |
| 690 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l3(i64 %0, i64 %1, i64 %2) |
| 691 |
|
| 692 |
typedef struct { |
| 693 |
long long l0; |
| 694 |
long long l1; |
| 695 |
long long l2; |
| 696 |
long long l3; |
| 697 |
} struct_l4; |
| 698 |
TEST(struct_l4) |
| 699 |
// CHECK-LABEL: define{{.*}} swiftcc { i64, i64, i64, i64 } @return_struct_l4() |
| 700 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l4(i64 %0, i64 %1, i64 %2, i64 %3) |
| 701 |
|
| 702 |
typedef struct { |
| 703 |
long long l0; |
| 704 |
long long l1; |
| 705 |
long long l2; |
| 706 |
long long l3; |
| 707 |
long long l4; |
| 708 |
} struct_l5; |
| 709 |
TEST(struct_l5) |
| 710 |
// CHECK: define{{.*}} swiftcc void @return_struct_l5(ptr dead_on_unwind noalias writable sret([[STRUCT5:.+]]) |
| 711 |
// CHECK: define{{.*}} swiftcc void @take_struct_l5(ptr |
| 712 |
|
| 713 |
typedef struct { |
| 714 |
char16 c0; |
| 715 |
} struct_vc1; |
| 716 |
TEST(struct_vc1) |
| 717 |
// CHECK-LABEL: define{{.*}} swiftcc <16 x i8> @return_struct_vc1() |
| 718 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc1(<16 x i8> %0) |
| 719 |
|
| 720 |
typedef struct { |
| 721 |
char16 c0; |
| 722 |
char16 c1; |
| 723 |
} struct_vc2; |
| 724 |
TEST(struct_vc2) |
| 725 |
// CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8> } @return_struct_vc2() |
| 726 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc2(<16 x i8> %0, <16 x i8> %1) |
| 727 |
|
| 728 |
typedef struct { |
| 729 |
char16 c0; |
| 730 |
char16 c1; |
| 731 |
char16 c2; |
| 732 |
} struct_vc3; |
| 733 |
TEST(struct_vc3) |
| 734 |
// CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc3() |
| 735 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc3(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2) |
| 736 |
|
| 737 |
typedef struct { |
| 738 |
char16 c0; |
| 739 |
char16 c1; |
| 740 |
char16 c2; |
| 741 |
char16 c3; |
| 742 |
} struct_vc4; |
| 743 |
TEST(struct_vc4) |
| 744 |
// CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc4() |
| 745 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc4(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2, <16 x i8> %3) |
| 746 |
|
| 747 |
typedef struct { |
| 748 |
char16 c0; |
| 749 |
char16 c1; |
| 750 |
char16 c2; |
| 751 |
char16 c3; |
| 752 |
char16 c4; |
| 753 |
} struct_vc5; |
| 754 |
TEST(struct_vc5) |
| 755 |
// CHECK: define{{.*}} swiftcc void @return_struct_vc5(ptr dead_on_unwind noalias writable sret([[STRUCT:.+]]) |
| 756 |
// CHECK: define{{.*}} swiftcc void @take_struct_vc5(ptr |
| 757 |
|
| 758 |
typedef struct { |
| 759 |
short8 c0; |
| 760 |
} struct_vs1; |
| 761 |
TEST(struct_vs1) |
| 762 |
// CHECK-LABEL: define{{.*}} swiftcc <8 x i16> @return_struct_vs1() |
| 763 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs1(<8 x i16> %0) |
| 764 |
|
| 765 |
typedef struct { |
| 766 |
short8 c0; |
| 767 |
short8 c1; |
| 768 |
} struct_vs2; |
| 769 |
TEST(struct_vs2) |
| 770 |
// CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16> } @return_struct_vs2() |
| 771 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs2(<8 x i16> %0, <8 x i16> %1) |
| 772 |
|
| 773 |
typedef struct { |
| 774 |
short8 c0; |
| 775 |
short8 c1; |
| 776 |
short8 c2; |
| 777 |
} struct_vs3; |
| 778 |
TEST(struct_vs3) |
| 779 |
// CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs3() |
| 780 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs3(<8 x i16> %0, <8 x i16> %1, <8 x i16> %2) |
| 781 |
|
| 782 |
typedef struct { |
| 783 |
short8 c0; |
| 784 |
short8 c1; |
| 785 |
short8 c2; |
| 786 |
short8 c3; |
| 787 |
} struct_vs4; |
| 788 |
TEST(struct_vs4) |
| 789 |
// CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs4() |
| 790 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs4(<8 x i16> %0, <8 x i16> %1, <8 x i16> %2, <8 x i16> %3) |
| 791 |
|
| 792 |
typedef struct { |
| 793 |
short8 c0; |
| 794 |
short8 c1; |
| 795 |
short8 c2; |
| 796 |
short8 c3; |
| 797 |
short8 c4; |
| 798 |
} struct_vs5; |
| 799 |
TEST(struct_vs5) |
| 800 |
// CHECK: define{{.*}} swiftcc void @return_struct_vs5(ptr dead_on_unwind noalias writable sret([[STRUCT:.+]]) |
| 801 |
// CHECK: define{{.*}} swiftcc void @take_struct_vs5(ptr |
| 802 |
|
| 803 |
typedef struct { |
| 804 |
int4 c0; |
| 805 |
} struct_vi1; |
| 806 |
TEST(struct_vi1) |
| 807 |
// CHECK-LABEL: define{{.*}} swiftcc <4 x i32> @return_struct_vi1() |
| 808 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi1(<4 x i32> %0) |
| 809 |
|
| 810 |
typedef struct { |
| 811 |
int4 c0; |
| 812 |
int4 c1; |
| 813 |
} struct_vi2; |
| 814 |
TEST(struct_vi2) |
| 815 |
// CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32> } @return_struct_vi2() |
| 816 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi2(<4 x i32> %0, <4 x i32> %1) |
| 817 |
|
| 818 |
typedef struct { |
| 819 |
int4 c0; |
| 820 |
int4 c1; |
| 821 |
int4 c2; |
| 822 |
} struct_vi3; |
| 823 |
TEST(struct_vi3) |
| 824 |
// CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32>, <4 x i32> } @return_struct_vi3() |
| 825 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi3(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2) |
| 826 |
|
| 827 |
typedef struct { |
| 828 |
int4 c0; |
| 829 |
int4 c1; |
| 830 |
int4 c2; |
| 831 |
int4 c3; |
| 832 |
} struct_vi4; |
| 833 |
TEST(struct_vi4) |
| 834 |
// CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32> } @return_struct_vi4() |
| 835 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi4(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2, <4 x i32> %3) |
| 836 |
|
| 837 |
typedef struct { |
| 838 |
int4 c0; |
| 839 |
int4 c1; |
| 840 |
int4 c2; |
| 841 |
int4 c3; |
| 842 |
int4 c4; |
| 843 |
} struct_vi5; |
| 844 |
TEST(struct_vi5) |
| 845 |
// CHECK: define{{.*}} swiftcc void @return_struct_vi5(ptr dead_on_unwind noalias writable sret([[STRUCT:.+]]) |
| 846 |
// CHECK: define{{.*}} swiftcc void @take_struct_vi5(ptr |
| 847 |
|
| 848 |
typedef struct { |
| 849 |
long2 c0; |
| 850 |
} struct_vl1; |
| 851 |
TEST(struct_vl1) |
| 852 |
// CHECK-LABEL: define{{.*}} swiftcc <2 x i64> @return_struct_vl1() |
| 853 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vl1(<2 x i64> %0) |
| 854 |
|
| 855 |
typedef struct { |
| 856 |
long2 c0; |
| 857 |
long2 c1; |
| 858 |
long2 c2; |
| 859 |
long2 c3; |
| 860 |
} struct_vl4; |
| 861 |
TEST(struct_vl4) |
| 862 |
// CHECK-LABEL: define{{.*}} swiftcc { <2 x i64>, <2 x i64>, <2 x i64>, <2 x i64> } @return_struct_vl4() |
| 863 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vl4(<2 x i64> %0, <2 x i64> %1, <2 x i64> %2, <2 x i64> %3) |
| 864 |
|
| 865 |
typedef struct { |
| 866 |
long2 c0; |
| 867 |
long2 c1; |
| 868 |
long2 c2; |
| 869 |
long2 c3; |
| 870 |
long2 c4; |
| 871 |
} struct_vl5; |
| 872 |
TEST(struct_vl5) |
| 873 |
// CHECK: define{{.*}} swiftcc void @return_struct_vl5(ptr dead_on_unwind noalias writable sret([[STRUCT:.+]]) |
| 874 |
// CHECK: define{{.*}} swiftcc void @take_struct_vl5(ptr |
| 875 |
|
| 876 |
typedef struct { |
| 877 |
double2 c0; |
| 878 |
} struct_vd1; |
| 879 |
TEST(struct_vd1) |
| 880 |
// CHECK-LABEL: define{{.*}} swiftcc <2 x double> @return_struct_vd1() |
| 881 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd1(<2 x double> %0) |
| 882 |
|
| 883 |
typedef struct { |
| 884 |
double2 c0; |
| 885 |
double2 c1; |
| 886 |
double2 c2; |
| 887 |
double2 c3; |
| 888 |
} struct_vd4; |
| 889 |
TEST(struct_vd4) |
| 890 |
// CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double>, <2 x double>, <2 x double> } @return_struct_vd4() |
| 891 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd4(<2 x double> %0, <2 x double> %1, <2 x double> %2, <2 x double> %3) |
| 892 |
|
| 893 |
typedef struct { |
| 894 |
double2 c0; |
| 895 |
double2 c1; |
| 896 |
double2 c2; |
| 897 |
double2 c3; |
| 898 |
double2 c4; |
| 899 |
} struct_vd5; |
| 900 |
TEST(struct_vd5) |
| 901 |
// CHECK: define{{.*}} swiftcc void @return_struct_vd5(ptr dead_on_unwind noalias writable sret([[STRUCT:.+]]) |
| 902 |
// CHECK: define{{.*}} swiftcc void @take_struct_vd5(ptr |
| 903 |
|
| 904 |
typedef struct { |
| 905 |
double4 c0; |
| 906 |
} struct_vd41; |
| 907 |
TEST(struct_vd41) |
| 908 |
// CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double> } @return_struct_vd41() |
| 909 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd41(<2 x double> %0, <2 x double> %1) |
| 910 |
|
| 911 |
typedef struct { |
| 912 |
double4 c0; |
| 913 |
double4 c1; |
| 914 |
} struct_vd42; |
| 915 |
TEST(struct_vd42) |
| 916 |
// CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double>, <2 x double>, <2 x double> } @return_struct_vd42() |
| 917 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd42(<2 x double> %0, <2 x double> %1, <2 x double> %2, <2 x double> %3) |
| 918 |
|
| 919 |
typedef struct { |
| 920 |
double4 c0; |
| 921 |
double4 c1; |
| 922 |
double4 c2; |
| 923 |
} struct_vd43; |
| 924 |
TEST(struct_vd43) |
| 925 |
// CHECK: define{{.*}} swiftcc void @return_struct_vd43(ptr dead_on_unwind noalias writable sret([[STRUCT:.+]]) |
| 926 |
// CHECK: define{{.*}} swiftcc void @take_struct_vd43(ptr |
| 927 |
|
| 928 |
typedef struct { |
| 929 |
float4 c0; |
| 930 |
} struct_vf1; |
| 931 |
TEST(struct_vf1) |
| 932 |
// CHECK-LABEL: define{{.*}} swiftcc <4 x float> @return_struct_vf1() |
| 933 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf1(<4 x float> %0) |
| 934 |
|
| 935 |
typedef struct { |
| 936 |
float4 c0; |
| 937 |
float4 c1; |
| 938 |
} struct_vf2; |
| 939 |
TEST(struct_vf2) |
| 940 |
// CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float> } @return_struct_vf2() |
| 941 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf2(<4 x float> %0, <4 x float> %1) |
| 942 |
|
| 943 |
typedef struct { |
| 944 |
float4 c0; |
| 945 |
float4 c1; |
| 946 |
float4 c2; |
| 947 |
float4 c3; |
| 948 |
} struct_vf4; |
| 949 |
TEST(struct_vf4) |
| 950 |
// CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float>, <4 x float>, <4 x float> } @return_struct_vf4() |
| 951 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf4(<4 x float> %0, <4 x float> %1, <4 x float> %2, <4 x float> %3) |
| 952 |
|
| 953 |
typedef struct { |
| 954 |
float4 c0; |
| 955 |
float4 c1; |
| 956 |
float4 c2; |
| 957 |
float4 c3; |
| 958 |
float4 c4; |
| 959 |
} struct_vf5; |
| 960 |
TEST(struct_vf5) |
| 961 |
// CHECK: define{{.*}} swiftcc void @return_struct_vf5(ptr dead_on_unwind noalias writable sret([[STRUCT:.+]]) |
| 962 |
// CHECK: define{{.*}} swiftcc void @take_struct_vf5(ptr |
| 963 |
|
| 964 |
typedef struct { |
| 965 |
float8 c0; |
| 966 |
} struct_vf81; |
| 967 |
TEST(struct_vf81) |
| 968 |
// CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float> } @return_struct_vf81() |
| 969 |
// CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf81(<4 x float> %0, <4 x float> %1) |
| 970 |
|
| 971 |
// Don't crash. |
| 972 |
typedef union { |
| 973 |
int4 v[2]; |
| 974 |
struct { |
| 975 |
int LSW; |
| 976 |
int d7; |
| 977 |
int d6; |
| 978 |
int d5; |
| 979 |
int d4; |
| 980 |
int d3; |
| 981 |
int d2; |
| 982 |
int MSW; |
| 983 |
} s; |
| 984 |
} union_het_vecint; |
| 985 |
TEST(union_het_vecint) |
| 986 |
// CHECK: define{{.*}} swiftcc { i64, i64, i64, i64 } @return_union_het_vecint() |
| 987 |
// CHECK: define{{.*}} swiftcc void @take_union_het_vecint(i64 %0, i64 %1, i64 %2, i64 %3) |
| 988 |
|
| 989 |
typedef struct { |
| 990 |
float3 f3; |
| 991 |
} struct_v1f3; |
| 992 |
TEST(struct_v1f3) |
| 993 |
// ARM64-LABEL: define{{.*}} swiftcc { <2 x float>, float } @return_struct_v1f3() |
| 994 |
// ARM64-LABEL: define{{.*}} swiftcc void @take_struct_v1f3(<2 x float> %0, float %1) |
| 995 |
|
| 996 |
typedef struct { |
| 997 |
int3 vect; |
| 998 |
unsigned long long val; |
| 999 |
} __attribute__((packed)) padded_alloc_size_vector; |
| 1000 |
TEST(padded_alloc_size_vector) |
| 1001 |
// X86-64-LABEL: take_padded_alloc_size_vector(<3 x i32> %0, i64 %1) |
| 1002 |
// X86-64-NOT: [4 x i8] |
| 1003 |
// x86-64: ret void |
| 1004 |
|
| 1005 |
typedef union { |
| 1006 |
float f1; |
| 1007 |
float3 fv2; |
| 1008 |
} union_hom_fp_partial2; |
| 1009 |
TEST(union_hom_fp_partial2) |
| 1010 |
// X86-64-LABEL: take_union_hom_fp_partial2(float %0, float %1, float %2) |
| 1011 |
// ARM64-LABEL: take_union_hom_fp_partial2(float %0, float %1, float %2) |
| 1012 |
|
| 1013 |
// At one point, we emitted lifetime.ends without a matching lifetime.start for |
| 1014 |
// CoerceAndExpanded args. Since we're not performing optimizations, neither |
| 1015 |
// intrinsic should be emitted. |
| 1016 |
// CHECK-LABEL: define{{.*}} void @no_lifetime_markers |
| 1017 |
void no_lifetime_markers() { |
| 1018 |
// CHECK-NOT: call void @llvm.lifetime. |
| 1019 |
take_int5(return_int5()); |
| 1020 |
} |
| 1021 |
|
| 1022 |
typedef struct { |
| 1023 |
unsigned long long a; |
| 1024 |
unsigned long long b; |
| 1025 |
} double_word; |
| 1026 |
|
| 1027 |
typedef struct { |
| 1028 |
_Atomic(double_word) a; |
| 1029 |
} atomic_double_word; |
| 1030 |
|
| 1031 |
// CHECK-LABEL: use_atomic(i64 %0, i64 %1) |
| 1032 |
SWIFTCALL void use_atomic(atomic_double_word a) {} |
| 1033 |
|
| 1034 |
typedef struct { |
| 1035 |
unsigned long long a; |
| 1036 |
unsigned char b; |
| 1037 |
} __attribute__((packed)) packed; |
| 1038 |
|
| 1039 |
typedef struct { |
| 1040 |
_Atomic(packed) a; |
| 1041 |
} atomic_padded; |
| 1042 |
|
| 1043 |
// CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1) |
| 1044 |
SWIFTCALL void use_atomic_padded(atomic_padded a) {} |
| 1045 |
|
| 1046 |
|
| 1047 |
typedef union { |
| 1048 |
float4 v; |
| 1049 |
float3 v2; |
| 1050 |
struct { |
| 1051 |
float a; |
| 1052 |
float b; |
| 1053 |
float c; |
| 1054 |
float d; |
| 1055 |
}; |
| 1056 |
} vector_union; |
| 1057 |
|
| 1058 |
TEST(vector_union) |
| 1059 |
|
| 1060 |
// CHECK-LABEL: define swiftcc { float, float, float, float } @return_vector_union() |
| 1061 |
// CHECK-LABEL: define swiftcc void @take_vector_union(float %0, float %1, float %2, float %3) |