Arnold Schwaighofer | 2d556f2 | 2016-10-13 17:17:36 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s |
| 2 | // RUN: %clang_cc1 -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s |
| 3 | |
Arnold Schwaighofer | c45025e | 2016-10-13 20:59:23 +0000 | [diff] [blame] | 4 | // REQUIRES: aarch64-registered-target,x86-registered-target |
| 5 | |
Arnold Schwaighofer | 18fad46 | 2016-10-13 22:47:03 +0000 | [diff] [blame] | 6 | // The union_het_vecint test case crashes on windows bot but only in stage1 and not in stage2. |
| 7 | // UNSUPPORTED: system-windows |
| 8 | |
Arnold Schwaighofer | 2d556f2 | 2016-10-13 17:17:36 +0000 | [diff] [blame] | 9 | #define SWIFTCALL __attribute__((swiftcall)) |
| 10 | #define OUT __attribute__((swift_indirect_result)) |
| 11 | #define ERROR __attribute__((swift_error_result)) |
| 12 | #define CONTEXT __attribute__((swift_context)) |
| 13 | |
| 14 | // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, float 0.000000e+00, float 0.000000e+00 } |
| 15 | |
| 16 | /*****************************************************************************/ |
| 17 | /****************************** PARAMETER ABIS *******************************/ |
| 18 | /*****************************************************************************/ |
| 19 | |
| 20 | SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {} |
| 21 | // CHECK-LABEL: define {{.*}} void @indirect_result_1(i32* noalias sret align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) |
| 22 | |
| 23 | // TODO: maybe this shouldn't suppress sret. |
| 24 | SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } |
| 25 | // CHECK-LABEL: define {{.*}} i32 @indirect_result_2(i32* noalias align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) |
| 26 | |
| 27 | typedef struct { char array[1024]; } struct_reallybig; |
| 28 | SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); } |
| 29 | // CHECK-LABEL: define {{.*}} void @indirect_result_3({{.*}}* noalias sret {{.*}}, i32* noalias align 4 dereferenceable(4){{.*}}, float* noalias align 4 dereferenceable(4){{.*}}) |
| 30 | |
| 31 | SWIFTCALL void context_1(CONTEXT void *self) {} |
| 32 | // CHECK-LABEL: define {{.*}} void @context_1(i8* swiftself |
| 33 | |
| 34 | SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {} |
| 35 | // CHECK-LABEL: define {{.*}} void @context_2(i8*{{.*}}, i8* swiftself |
| 36 | |
| 37 | SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {} |
| 38 | // CHECK-LABEL: define {{.*}} void @context_error_1(i32* swiftself{{.*}}, float** swifterror) |
| 39 | // CHECK: [[TEMP:%.*]] = alloca float*, align 8 |
| 40 | // CHECK: [[T0:%.*]] = load float*, float** [[ERRORARG:%.*]], align 8 |
| 41 | // CHECK: store float* [[T0]], float** [[TEMP]], align 8 |
| 42 | // CHECK: [[T0:%.*]] = load float*, float** [[TEMP]], align 8 |
| 43 | // CHECK: store float* [[T0]], float** [[ERRORARG]], align 8 |
| 44 | void test_context_error_1() { |
| 45 | int x; |
| 46 | float *error; |
| 47 | context_error_1(&x, &error); |
| 48 | } |
| 49 | // CHECK-LABEL: define void @test_context_error_1() |
| 50 | // CHECK: [[X:%.*]] = alloca i32, align 4 |
| 51 | // CHECK: [[ERROR:%.*]] = alloca float*, align 8 |
| 52 | // CHECK: [[TEMP:%.*]] = alloca swifterror float*, align 8 |
| 53 | // CHECK: [[T0:%.*]] = load float*, float** [[ERROR]], align 8 |
| 54 | // CHECK: store float* [[T0]], float** [[TEMP]], align 8 |
| 55 | // CHECK: call [[SWIFTCC:swiftcc]] void @context_error_1(i32* swiftself [[X]], float** swifterror [[TEMP]]) |
| 56 | // CHECK: [[T0:%.*]] = load float*, float** [[TEMP]], align 8 |
| 57 | // CHECK: store float* [[T0]], float** [[ERROR]], align 8 |
| 58 | |
| 59 | SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float **error) {} |
| 60 | // CHECK-LABEL: define {{.*}} void @context_error_2(i16{{.*}}, i32* swiftself{{.*}}, float** swifterror) |
| 61 | |
| 62 | /*****************************************************************************/ |
| 63 | /********************************** LOWERING *********************************/ |
| 64 | /*****************************************************************************/ |
| 65 | |
| 66 | typedef float float4 __attribute__((ext_vector_type(4))); |
| 67 | typedef float float8 __attribute__((ext_vector_type(8))); |
| 68 | typedef double double2 __attribute__((ext_vector_type(2))); |
| 69 | typedef double double4 __attribute__((ext_vector_type(4))); |
| 70 | typedef int int3 __attribute__((ext_vector_type(3))); |
| 71 | typedef int int4 __attribute__((ext_vector_type(4))); |
| 72 | typedef int int5 __attribute__((ext_vector_type(5))); |
| 73 | typedef int int8 __attribute__((ext_vector_type(8))); |
| 74 | |
| 75 | #define TEST(TYPE) \ |
| 76 | SWIFTCALL TYPE return_##TYPE(void) { \ |
| 77 | TYPE result = {}; \ |
| 78 | return result; \ |
| 79 | } \ |
| 80 | SWIFTCALL void take_##TYPE(TYPE v) { \ |
| 81 | } \ |
| 82 | void test_##TYPE() { \ |
| 83 | take_##TYPE(return_##TYPE()); \ |
| 84 | } |
| 85 | |
| 86 | /*****************************************************************************/ |
| 87 | /*********************************** STRUCTS *********************************/ |
| 88 | /*****************************************************************************/ |
| 89 | |
| 90 | typedef struct { |
| 91 | } struct_empty; |
| 92 | TEST(struct_empty); |
| 93 | // CHECK-LABEL: define {{.*}} @return_struct_empty() |
| 94 | // CHECK: ret void |
| 95 | // CHECK-LABEL: define {{.*}} @take_struct_empty() |
| 96 | // CHECK: ret void |
| 97 | |
| 98 | typedef struct { |
| 99 | int x; |
| 100 | char c0; |
| 101 | char c1; |
| 102 | float f0; |
| 103 | float f1; |
| 104 | } struct_1; |
| 105 | TEST(struct_1); |
| 106 | // CHECK-LABEL: define swiftcc { i64, i64 } @return_struct_1() {{.*}}{ |
| 107 | // CHECK: [[RET:%.*]] = alloca [[STRUCT1:%.*]], align 4 |
| 108 | // CHECK: [[VAR:%.*]] = alloca [[STRUCT1]], align 4 |
| 109 | // CHECK: call void @llvm.memset |
| 110 | // CHECK: call void @llvm.memcpy |
| 111 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT1]]* %retval to { i64, i64 }* |
| 112 | // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 113 | // CHECK: [[T0:%.*]] = load i64, i64* [[GEP0]], align 4 |
| 114 | // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 115 | // CHECK: [[T1:%.*]] = load i64, i64* [[GEP1]], align 4 |
| 116 | // CHECK: [[R0:%.*]] = insertvalue { i64, i64 } undef, i64 [[T0]], 0 |
| 117 | // CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1 |
| 118 | // CHECK: ret { i64, i64 } [[R1]] |
| 119 | // CHECK: } |
| 120 | // CHECK-LABEL: define swiftcc void @take_struct_1(i64, i64) {{.*}}{ |
| 121 | // CHECK: [[V:%.*]] = alloca [[STRUCT1:%.*]], align 4 |
| 122 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT1]]* [[V]] to { i64, i64 }* |
| 123 | // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 124 | // CHECK: store i64 %0, i64* [[GEP0]], align 4 |
| 125 | // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 126 | // CHECK: store i64 %1, i64* [[GEP1]], align 4 |
| 127 | // CHECK: ret void |
| 128 | // CHECK: } |
| 129 | // CHECK-LABEL: define void @test_struct_1() {{.*}}{ |
| 130 | // CHECK: [[AGG:%.*]] = alloca [[STRUCT1:%.*]], align 4 |
| 131 | // CHECK: [[RET:%.*]] = call swiftcc { i64, i64 } @return_struct_1() |
| 132 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT1]]* [[AGG]] to { i64, i64 }* |
| 133 | // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 134 | // CHECK: [[E0:%.*]] = extractvalue { i64, i64 } [[RET]], 0 |
| 135 | // CHECK: store i64 [[E0]], i64* [[GEP0]], align 4 |
| 136 | // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 137 | // CHECK: [[E1:%.*]] = extractvalue { i64, i64 } [[RET]], 1 |
| 138 | // CHECK: store i64 [[E1]], i64* [[GEP1]], align 4 |
| 139 | // CHECK: [[CAST2:%.*]] = bitcast [[STRUCT1]]* [[AGG]] to { i64, i64 }* |
| 140 | // CHECK: [[GEP2:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST2]], i32 0, i32 0 |
| 141 | // CHECK: [[V0:%.*]] = load i64, i64* [[GEP2]], align 4 |
| 142 | // CHECK: [[GEP3:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST2]], i32 0, i32 1 |
| 143 | // CHECK: [[V1:%.*]] = load i64, i64* [[GEP3]], align 4 |
| 144 | // CHECK: call swiftcc void @take_struct_1(i64 [[V0]], i64 [[V1]]) |
| 145 | // CHECK: ret void |
| 146 | // CHECK: } |
| 147 | |
| 148 | typedef struct { |
| 149 | int x; |
| 150 | char c0; |
| 151 | __attribute__((aligned(2))) char c1; |
| 152 | float f0; |
| 153 | float f1; |
| 154 | } struct_2; |
| 155 | TEST(struct_2); |
| 156 | // CHECK-LABEL: define swiftcc { i64, i64 } @return_struct_2() {{.*}}{ |
| 157 | // CHECK: [[RET:%.*]] = alloca [[STRUCT2_TYPE]], align 4 |
| 158 | // CHECK: [[VAR:%.*]] = alloca [[STRUCT2_TYPE]], align 4 |
| 159 | // CHECK: [[CASTVAR:%.*]] = bitcast {{.*}} [[VAR]] |
| 160 | // CHECK: call void @llvm.memcpy{{.*}}({{.*}}[[CASTVAR]], {{.*}}[[STRUCT2_RESULT]] |
| 161 | // CHECK: [[CASTRET:%.*]] = bitcast {{.*}} [[RET]] |
| 162 | // CHECK: [[CASTVAR:%.*]] = bitcast {{.*}} [[VAR]] |
| 163 | // CHECK: call void @llvm.memcpy{{.*}}({{.*}}[[CASTRET]], {{.*}}[[CASTVAR]] |
| 164 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT2_TYPE]]* [[RET]] to { i64, i64 }* |
| 165 | // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 166 | // CHECK: [[T0:%.*]] = load i64, i64* [[GEP0]], align 4 |
| 167 | // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 168 | // CHECK: [[T1:%.*]] = load i64, i64* [[GEP1]], align 4 |
| 169 | // CHECK: [[R0:%.*]] = insertvalue { i64, i64 } undef, 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, i64) {{.*}}{ |
| 174 | // CHECK: [[V:%.*]] = alloca [[STRUCT:%.*]], align 4 |
| 175 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT]]* [[V]] to { i64, i64 }* |
| 176 | // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 177 | // CHECK: store i64 %0, i64* [[GEP0]], align 4 |
| 178 | // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 179 | // CHECK: store i64 %1, i64* [[GEP1]], align 4 |
| 180 | // CHECK: ret void |
| 181 | // CHECK: } |
| 182 | // CHECK-LABEL: define void @test_struct_2() {{.*}} { |
| 183 | // CHECK: [[TMP:%.*]] = alloca [[STRUCT2_TYPE]], align 4 |
| 184 | // CHECK: [[CALL:%.*]] = call swiftcc { i64, i64 } @return_struct_2() |
| 185 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[STRUCT2_TYPE]]* [[TMP]] to { i64, i64 }* |
| 186 | // CHECK: [[GEP:%.*]] = getelementptr inbounds {{.*}} [[CAST_TMP]], i32 0, i32 0 |
| 187 | // CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 0 |
| 188 | // CHECK: store i64 [[T0]], i64* [[GEP]], align 4 |
| 189 | // CHECK: [[GEP:%.*]] = getelementptr inbounds {{.*}} [[CAST_TMP]], i32 0, i32 1 |
| 190 | // CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 1 |
| 191 | // CHECK: store i64 [[T0]], i64* [[GEP]], align 4 |
| 192 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT2_TYPE]]* [[TMP]] to { i64, i64 }* |
| 193 | // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 194 | // CHECK: [[R0:%.*]] = load i64, i64* [[GEP]], align 4 |
| 195 | // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 196 | // CHECK: [[R1:%.*]] = load i64, i64* [[GEP]], align 4 |
| 197 | // CHECK: call swiftcc void @take_struct_2(i64 [[R0]], i64 [[R1]]) |
| 198 | // CHECK: ret void |
| 199 | // CHECK: } |
| 200 | |
| 201 | // There's no way to put a field randomly in the middle of an otherwise |
| 202 | // empty storage unit in C, so that case has to be tested in C++, which |
| 203 | // can use empty structs to introduce arbitrary padding. (In C, they end up |
| 204 | // with size 0 and so don't affect layout.) |
| 205 | |
| 206 | // Misaligned data rule. |
| 207 | typedef struct { |
| 208 | char c0; |
| 209 | __attribute__((packed)) float f; |
| 210 | } struct_misaligned_1; |
| 211 | TEST(struct_misaligned_1) |
| 212 | // CHECK-LABEL: define swiftcc i64 @return_struct_misaligned_1() |
| 213 | // CHECK: [[RET:%.*]] = alloca [[STRUCT:%.*]], align 1 |
| 214 | // CHECK: [[RES:%.*]] = alloca [[STRUCT]], align 1 |
| 215 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT]]* [[RES]] to i8* |
| 216 | // CHECK: call void @llvm.memset{{.*}}(i8* [[CAST]], i8 0, i64 5 |
| 217 | // CHECK: [[CASTRET:%.*]] = bitcast [[STRUCT]]* [[RET]] to i8* |
| 218 | // CHECK: [[CASTRES:%.*]] = bitcast [[STRUCT]]* [[RES]] to i8* |
| 219 | // CHECK: call void @llvm.memcpy{{.*}}(i8* [[CASTRET]], i8* [[CASTRES]], i64 5 |
| 220 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT]]* [[RET]] to { i64 }* |
| 221 | // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[CAST]], i32 0, i32 0 |
| 222 | // CHECK: [[R0:%.*]] = load i64, i64* [[GEP]], align 1 |
| 223 | // CHECK: ret i64 [[R0]] |
| 224 | // CHECK:} |
| 225 | // CHECK-LABEL: define swiftcc void @take_struct_misaligned_1(i64) {{.*}}{ |
| 226 | // CHECK: [[V:%.*]] = alloca [[STRUCT:%.*]], align 1 |
| 227 | // CHECK: [[CAST:%.*]] = bitcast [[STRUCT]]* [[V]] to { i64 }* |
| 228 | // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[CAST]], i32 0, i32 0 |
| 229 | // CHECK: store i64 %0, i64* [[GEP]], align 1 |
| 230 | // CHECK: ret void |
| 231 | // CHECK: } |
| 232 | // CHECK: define void @test_struct_misaligned_1() {{.*}}{ |
| 233 | // CHECK: [[AGG:%.*]] = alloca [[STRUCT:%.*]], align 1 |
| 234 | // CHECK: [[CALL:%.*]] = call swiftcc i64 @return_struct_misaligned_1() |
| 235 | // CHECK: [[T0:%.*]] = bitcast [[STRUCT]]* [[AGG]] to { i64 }* |
| 236 | // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[T0]], i32 0, i32 0 |
| 237 | // CHECK: store i64 [[CALL]], i64* [[T1]], align 1 |
| 238 | // CHECK: [[T0:%.*]] = bitcast [[STRUCT]]* [[AGG]] to { i64 }* |
| 239 | // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[T0]], i32 0, i32 0 |
| 240 | // CHECK: [[P:%.*]] = load i64, i64* [[T1]], align 1 |
| 241 | // CHECK: call swiftcc void @take_struct_misaligned_1(i64 [[P]]) |
| 242 | // CHECK: ret void |
| 243 | // CHECK: } |
| 244 | |
| 245 | // Too many scalars. |
| 246 | typedef struct { |
| 247 | long long x[5]; |
| 248 | } struct_big_1; |
| 249 | TEST(struct_big_1) |
| 250 | |
| 251 | // CHECK-LABEL: define {{.*}} void @return_struct_big_1({{.*}} noalias sret |
| 252 | |
| 253 | // Should not be byval. |
| 254 | // CHECK-LABEL: define {{.*}} void @take_struct_big_1({{.*}}*{{( %.*)?}}) |
| 255 | |
| 256 | /*****************************************************************************/ |
| 257 | /********************************* TYPE MERGING ******************************/ |
| 258 | /*****************************************************************************/ |
| 259 | |
| 260 | typedef union { |
| 261 | float f; |
| 262 | double d; |
| 263 | } union_het_fp; |
| 264 | TEST(union_het_fp) |
| 265 | // CHECK-LABEL: define swiftcc i64 @return_union_het_fp() |
| 266 | // CHECK: [[RET:%.*]] = alloca [[UNION:%.*]], align 8 |
| 267 | // CHECK: [[RES:%.*]] = alloca [[UNION]], align 8 |
| 268 | // CHECK: [[CAST:%.*]] = bitcast [[UNION]]* [[RES]] to i8* |
| 269 | // CHECK: call void @llvm.memcpy{{.*}}(i8* [[CAST]] |
| 270 | // CHECK: [[CASTRET:%.*]] = bitcast [[UNION]]* [[RET]] to i8* |
| 271 | // CHECK: [[CASTRES:%.*]] = bitcast [[UNION]]* [[RES]] to i8* |
| 272 | // CHECK: call void @llvm.memcpy{{.*}}(i8* [[CASTRET]], i8* [[CASTRES]] |
| 273 | // CHECK: [[CAST:%.*]] = bitcast [[UNION]]* [[RET]] to { i64 }* |
| 274 | // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[CAST]], i32 0, i32 0 |
| 275 | // CHECK: [[R0:%.*]] = load i64, i64* [[GEP]], align 8 |
| 276 | // CHECK: ret i64 [[R0]] |
| 277 | // CHECK-LABEL: define swiftcc void @take_union_het_fp(i64) {{.*}}{ |
| 278 | // CHECK: [[V:%.*]] = alloca [[UNION:%.*]], align 8 |
| 279 | // CHECK: [[CAST:%.*]] = bitcast [[UNION]]* [[V]] to { i64 }* |
| 280 | // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[CAST]], i32 0, i32 0 |
| 281 | // CHECK: store i64 %0, i64* [[GEP]], align 8 |
| 282 | // CHECK: ret void |
| 283 | // CHECK: } |
| 284 | // CHECK-LABEL: define void @test_union_het_fp() {{.*}}{ |
| 285 | // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 8 |
| 286 | // CHECK: [[CALL:%.*]] = call swiftcc i64 @return_union_het_fp() |
| 287 | // CHECK: [[T0:%.*]] = bitcast [[UNION]]* [[AGG]] to { i64 }* |
| 288 | // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[T0]], i32 0, i32 0 |
| 289 | // CHECK: store i64 [[CALL]], i64* [[T1]], align 8 |
| 290 | // CHECK: [[T0:%.*]] = bitcast [[UNION]]* [[AGG]] to { i64 }* |
| 291 | // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, { i64 }* [[T0]], i32 0, i32 0 |
| 292 | // CHECK: [[V0:%.*]] = load i64, i64* [[T1]], align 8 |
| 293 | // CHECK: call swiftcc void @take_union_het_fp(i64 [[V0]]) |
| 294 | // CHECK: ret void |
| 295 | // CHECK: } |
| 296 | |
| 297 | |
| 298 | typedef union { |
| 299 | float f1; |
| 300 | float f2; |
| 301 | } union_hom_fp; |
| 302 | TEST(union_hom_fp) |
| 303 | // CHECK-LABEL: define void @test_union_hom_fp() |
| 304 | // CHECK: [[TMP:%.*]] = alloca [[REC:%.*]], align 4 |
| 305 | // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] float @return_union_hom_fp() |
| 306 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[TMP]] to [[AGG:{ float }]]* |
| 307 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 308 | // CHECK: store float [[CALL]], float* [[T0]], align 4 |
| 309 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[TMP]] to [[AGG]]* |
| 310 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 311 | // CHECK: [[FIRST:%.*]] = load float, float* [[T0]], align 4 |
| 312 | // CHECK: call [[SWIFTCC]] void @take_union_hom_fp(float [[FIRST]]) |
| 313 | // CHECK: ret void |
| 314 | |
| 315 | typedef union { |
| 316 | float f1; |
| 317 | float4 fv2; |
| 318 | } union_hom_fp_partial; |
| 319 | TEST(union_hom_fp_partial) |
| 320 | // CHECK: define void @test_union_hom_fp_partial() |
| 321 | // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16 |
| 322 | // CHECK: [[CALL:%.*]] = call swiftcc { i64, i64 } @return_union_hom_fp_partial() |
| 323 | // CHECK: [[CAST:%.*]] = bitcast [[UNION]]* [[AGG]] to { i64, i64 }* |
| 324 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 325 | // CHECK: [[T1:%.*]] = extractvalue { i64, i64 } [[CALL]], 0 |
| 326 | // CHECK: store i64 [[T1]], i64* [[T0]], align 16 |
| 327 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 328 | // CHECK: [[T1:%.*]] = extractvalue { i64, i64 } [[CALL]], 1 |
| 329 | // CHECK: store i64 [[T1]], i64* [[T0]], align 8 |
| 330 | // CHECK: [[CAST:%.*]] = bitcast [[UNION]]* [[AGG]] to { i64, i64 }* |
| 331 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 332 | // CHECK: [[V0:%.*]] = load i64, i64* [[T0]], align 16 |
| 333 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 334 | // CHECK: [[V1:%.*]] = load i64, i64* [[T0]], align 8 |
| 335 | // CHECK: call swiftcc void @take_union_hom_fp_partial(i64 [[V0]], i64 [[V1]]) |
| 336 | // CHECK: ret void |
| 337 | // CHECK: } |
| 338 | |
| 339 | typedef union { |
| 340 | struct { int x, y; } f1; |
| 341 | float4 fv2; |
| 342 | } union_het_fpv_partial; |
| 343 | TEST(union_het_fpv_partial) |
| 344 | // CHECK-LABEL: define void @test_union_het_fpv_partial() |
| 345 | // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16 |
| 346 | // CHECK: [[CALL:%.*]] = call swiftcc { i64, i64 } @return_union_het_fpv_partial() |
| 347 | // CHECK: [[CAST:%.*]] = bitcast [[UNION]]* [[AGG]] to { i64, i64 }* |
| 348 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 349 | // CHECK: [[T1:%.*]] = extractvalue { i64, i64 } [[CALL]], 0 |
| 350 | // CHECK: store i64 [[T1]], i64* [[T0]], align 16 |
| 351 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 352 | // CHECK: [[T1:%.*]] = extractvalue { i64, i64 } [[CALL]], 1 |
| 353 | // CHECK: store i64 [[T1]], i64* [[T0]], align 8 |
| 354 | // CHECK: [[CAST:%.*]] = bitcast [[UNION]]* [[AGG]] to { i64, i64 }* |
| 355 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 0 |
| 356 | // CHECK: [[V0:%.*]] = load i64, i64* [[T0]], align 16 |
| 357 | // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 |
| 358 | // CHECK: [[V1:%.*]] = load i64, i64* [[T0]], align 8 |
| 359 | // CHECK: call swiftcc void @take_union_het_fpv_partial(i64 [[V0]], i64 [[V1]]) |
| 360 | // CHECK: ret void |
| 361 | // CHECK: } |
| 362 | |
| 363 | /*****************************************************************************/ |
| 364 | /****************************** VECTOR LEGALIZATION **************************/ |
| 365 | /*****************************************************************************/ |
| 366 | |
| 367 | TEST(int4) |
| 368 | // CHECK-LABEL: define {{.*}} <4 x i32> @return_int4() |
| 369 | // CHECK-LABEL: define {{.*}} @take_int4(<4 x i32> |
| 370 | |
| 371 | TEST(int8) |
| 372 | // CHECK-LABEL: define {{.*}} @return_int8() |
| 373 | // CHECK: [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 16 |
| 374 | // CHECK: [[VAR:%.*]] = alloca [[REC]], align |
| 375 | // CHECK: store |
| 376 | // CHECK: load |
| 377 | // CHECK: store |
| 378 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ <4 x i32>, <4 x i32> }]]* |
| 379 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 380 | // CHECK: [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align |
| 381 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 382 | // CHECK: [[SECOND:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align |
| 383 | // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] undef, <4 x i32> [[FIRST]], 0 |
| 384 | // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1 |
| 385 | // CHECK: ret [[UAGG]] [[T1]] |
| 386 | // CHECK-LABEL: define {{.*}} @take_int8(<4 x i32>, <4 x i32>) |
| 387 | // CHECK: [[V:%.*]] = alloca [[REC]], align |
| 388 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[V]] to [[AGG]]* |
| 389 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 390 | // CHECK: store <4 x i32> %0, <4 x i32>* [[T0]], align |
| 391 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 392 | // CHECK: store <4 x i32> %1, <4 x i32>* [[T0]], align |
| 393 | // CHECK: ret void |
| 394 | // CHECK-LABEL: define void @test_int8() |
| 395 | // CHECK: [[TMP1:%.*]] = alloca [[REC]], align |
| 396 | // CHECK: [[TMP2:%.*]] = alloca [[REC]], align |
| 397 | // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int8() |
| 398 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[TMP1]] to [[AGG]]* |
| 399 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 400 | // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0 |
| 401 | // CHECK: store <4 x i32> [[T1]], <4 x i32>* [[T0]], align |
| 402 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 403 | // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1 |
| 404 | // CHECK: store <4 x i32> [[T1]], <4 x i32>* [[T0]], align |
| 405 | // CHECK: [[V:%.*]] = load [[REC]], [[REC]]* [[TMP1]], align |
| 406 | // CHECK: store [[REC]] [[V]], [[REC]]* [[TMP2]], align |
| 407 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[TMP2]] to [[AGG]]* |
| 408 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 409 | // CHECK: [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align |
| 410 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 411 | // CHECK: [[SECOND:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align |
| 412 | // CHECK: call [[SWIFTCC]] void @take_int8(<4 x i32> [[FIRST]], <4 x i32> [[SECOND]]) |
| 413 | // CHECK: ret void |
| 414 | |
| 415 | TEST(int5) |
| 416 | // CHECK-LABEL: define {{.*}} @return_int5() |
| 417 | // CHECK: [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 16 |
| 418 | // CHECK: [[VAR:%.*]] = alloca [[REC]], align |
| 419 | // CHECK: store |
| 420 | // CHECK: load |
| 421 | // CHECK: store |
| 422 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[RET]] to [[AGG:{ <4 x i32>, i32 }]]* |
| 423 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 424 | // CHECK: [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align |
| 425 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 426 | // CHECK: [[SECOND:%.*]] = load i32, i32* [[T0]], align |
| 427 | // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] undef, <4 x i32> [[FIRST]], 0 |
| 428 | // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1 |
| 429 | // CHECK: ret [[UAGG]] [[T1]] |
| 430 | // CHECK-LABEL: define {{.*}} @take_int5(<4 x i32>, i32) |
| 431 | // CHECK: [[V:%.*]] = alloca [[REC]], align |
| 432 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[V]] to [[AGG]]* |
| 433 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 434 | // CHECK: store <4 x i32> %0, <4 x i32>* [[T0]], align |
| 435 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 436 | // CHECK: store i32 %1, i32* [[T0]], align |
| 437 | // CHECK: ret void |
| 438 | // CHECK-LABEL: define void @test_int5() |
| 439 | // CHECK: [[TMP1:%.*]] = alloca [[REC]], align |
| 440 | // CHECK: [[TMP2:%.*]] = alloca [[REC]], align |
| 441 | // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int5() |
| 442 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[TMP1]] to [[AGG]]* |
| 443 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 444 | // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0 |
| 445 | // CHECK: store <4 x i32> [[T1]], <4 x i32>* [[T0]], align |
| 446 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 447 | // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1 |
| 448 | // CHECK: store i32 [[T1]], i32* [[T0]], align |
| 449 | // CHECK: [[V:%.*]] = load [[REC]], [[REC]]* [[TMP1]], align |
| 450 | // CHECK: store [[REC]] [[V]], [[REC]]* [[TMP2]], align |
| 451 | // CHECK: [[CAST_TMP:%.*]] = bitcast [[REC]]* [[TMP2]] to [[AGG]]* |
| 452 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 0 |
| 453 | // CHECK: [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align |
| 454 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 |
| 455 | // CHECK: [[SECOND:%.*]] = load i32, i32* [[T0]], align |
| 456 | // CHECK: call [[SWIFTCC]] void @take_int5(<4 x i32> [[FIRST]], i32 [[SECOND]]) |
| 457 | // CHECK: ret void |
| 458 | |
| 459 | typedef struct { |
| 460 | int x; |
| 461 | int3 v __attribute__((packed)); |
| 462 | } misaligned_int3; |
| 463 | TEST(misaligned_int3) |
| 464 | // CHECK-LABEL: define swiftcc void @take_misaligned_int3(i64, i64) |
| 465 | |
| 466 | typedef struct { |
| 467 | float f0; |
| 468 | } struct_f1; |
| 469 | TEST(struct_f1) |
| 470 | // CHECK-LABEL: define swiftcc float @return_struct_f1() |
| 471 | // CHECK-LABEL: define swiftcc void @take_struct_f1(float) |
| 472 | |
| 473 | typedef struct { |
| 474 | float f0; |
| 475 | float f1; |
| 476 | } struct_f2; |
| 477 | TEST(struct_f2) |
| 478 | // CHECK-LABEL: define swiftcc i64 @return_struct_f2() |
| 479 | // CHECK-LABEL: define swiftcc void @take_struct_f2(i64) |
| 480 | |
| 481 | typedef struct { |
| 482 | float f0; |
| 483 | float f1; |
| 484 | float f2; |
| 485 | } struct_f3; |
| 486 | TEST(struct_f3) |
| 487 | // CHECK-LABEL: define swiftcc { i64, float } @return_struct_f3() |
| 488 | // CHECK-LABEL: define swiftcc void @take_struct_f3(i64, float) |
| 489 | |
| 490 | typedef struct { |
| 491 | float f0; |
| 492 | float f1; |
| 493 | float f2; |
| 494 | float f3; |
| 495 | } struct_f4; |
| 496 | TEST(struct_f4) |
| 497 | // CHECK-LABEL: define swiftcc { i64, i64 } @return_struct_f4() |
| 498 | // CHECK-LABEL: define swiftcc void @take_struct_f4(i64, i64) |
| 499 | |
| 500 | |
| 501 | typedef struct { |
| 502 | double d0; |
| 503 | } struct_d1; |
| 504 | TEST(struct_d1) |
| 505 | // CHECK-LABEL: define swiftcc double @return_struct_d1() |
| 506 | // CHECK-LABEL: define swiftcc void @take_struct_d1(double) |
| 507 | |
| 508 | typedef struct { |
| 509 | double d0; |
| 510 | double d1; |
| 511 | } struct_d2; |
| 512 | TEST(struct_d2) |
| 513 | // CHECK-LABEL: define swiftcc { double, double } @return_struct_d2() |
| 514 | // CHECK-LABEL: define swiftcc void @take_struct_d2(double, double) |
| 515 | |
| 516 | typedef struct { |
| 517 | char c0; |
| 518 | } struct_c1; |
| 519 | TEST(struct_c1) |
| 520 | // CHECK-LABEL: define swiftcc i8 @return_struct_c1() |
| 521 | // CHECK-LABEL: define swiftcc void @take_struct_c1(i8) |
| 522 | |
| 523 | typedef struct { |
| 524 | char c0; |
| 525 | char c1; |
| 526 | } struct_c2; |
| 527 | TEST(struct_c2) |
| 528 | // CHECK-LABEL: define swiftcc i16 @return_struct_c2() |
| 529 | // CHECK-LABEL: define swiftcc void @take_struct_c2(i16) |
| 530 | // |
| 531 | |
| 532 | typedef struct { |
| 533 | char c0; |
| 534 | char c1; |
| 535 | char c2; |
| 536 | } struct_c3; |
| 537 | TEST(struct_c3) |
| 538 | // CHECK-LABEL: define swiftcc i32 @return_struct_c3() |
| 539 | // CHECK-LABEL: define swiftcc void @take_struct_c3(i32) |
| 540 | |
| 541 | typedef struct { |
| 542 | char c0; |
| 543 | char c1; |
| 544 | char c2; |
| 545 | char c3; |
| 546 | } struct_c4; |
| 547 | TEST(struct_c4) |
| 548 | // CHECK-LABEL: define swiftcc i32 @return_struct_c4() |
| 549 | // CHECK-LABEL: define swiftcc void @take_struct_c4(i32) |
| 550 | |
| 551 | typedef struct { |
| 552 | char c0; |
| 553 | char c1; |
| 554 | char c2; |
| 555 | char c3; |
| 556 | char c4; |
| 557 | } struct_c5; |
| 558 | TEST(struct_c5) |
| 559 | // CHECK-LABEL: define swiftcc i64 @return_struct_c5() |
| 560 | // CHECK-LABEL: define swiftcc void @take_struct_c5(i64) |
| 561 | // |
| 562 | typedef struct { |
| 563 | char c0; |
| 564 | char c1; |
| 565 | char c2; |
| 566 | char c3; |
| 567 | char c4; |
| 568 | char c5; |
| 569 | char c6; |
| 570 | char c7; |
| 571 | char c8; |
| 572 | } struct_c9; |
| 573 | TEST(struct_c9) |
| 574 | // CHECK-LABEL: define swiftcc { i64, i8 } @return_struct_c9() |
| 575 | // CHECK-LABEL: define swiftcc void @take_struct_c9(i64, i8) |
| 576 | |
| 577 | typedef struct { |
| 578 | short s0; |
| 579 | } struct_s1; |
| 580 | TEST(struct_s1) |
| 581 | // CHECK-LABEL: define swiftcc i16 @return_struct_s1() |
| 582 | // CHECK-LABEL: define swiftcc void @take_struct_s1(i16) |
| 583 | |
| 584 | typedef struct { |
| 585 | short s0; |
| 586 | short s1; |
| 587 | } struct_s2; |
| 588 | TEST(struct_s2) |
| 589 | // CHECK-LABEL: define swiftcc i32 @return_struct_s2() |
| 590 | // CHECK-LABEL: define swiftcc void @take_struct_s2(i32) |
| 591 | // |
| 592 | |
| 593 | typedef struct { |
| 594 | short s0; |
| 595 | short s1; |
| 596 | short s2; |
| 597 | } struct_s3; |
| 598 | TEST(struct_s3) |
| 599 | // CHECK-LABEL: define swiftcc i64 @return_struct_s3() |
| 600 | // CHECK-LABEL: define swiftcc void @take_struct_s3(i64) |
| 601 | |
| 602 | typedef struct { |
| 603 | short s0; |
| 604 | short s1; |
| 605 | short s2; |
| 606 | short s3; |
| 607 | } struct_s4; |
| 608 | TEST(struct_s4) |
| 609 | // CHECK-LABEL: define swiftcc i64 @return_struct_s4() |
| 610 | // CHECK-LABEL: define swiftcc void @take_struct_s4(i64) |
| 611 | |
| 612 | typedef struct { |
| 613 | short s0; |
| 614 | short s1; |
| 615 | short s2; |
| 616 | short s3; |
| 617 | short s4; |
| 618 | } struct_s5; |
| 619 | TEST(struct_s5) |
| 620 | // CHECK-LABEL: define swiftcc { i64, i16 } @return_struct_s5() |
| 621 | // CHECK-LABEL: define swiftcc void @take_struct_s5(i64, i16) |
| 622 | |
| 623 | |
| 624 | typedef struct { |
| 625 | int i0; |
| 626 | } struct_i1; |
| 627 | TEST(struct_i1) |
| 628 | // CHECK-LABEL: define swiftcc i32 @return_struct_i1() |
| 629 | // CHECK-LABEL: define swiftcc void @take_struct_i1(i32) |
| 630 | |
| 631 | typedef struct { |
| 632 | int i0; |
| 633 | int i1; |
| 634 | } struct_i2; |
| 635 | TEST(struct_i2) |
| 636 | // CHECK-LABEL: define swiftcc i64 @return_struct_i2() |
| 637 | // CHECK-LABEL: define swiftcc void @take_struct_i2(i64) |
| 638 | |
| 639 | typedef struct { |
| 640 | int i0; |
| 641 | int i1; |
| 642 | int i2; |
| 643 | } struct_i3; |
| 644 | TEST(struct_i3) |
| 645 | // CHECK-LABEL: define swiftcc { i64, i32 } @return_struct_i3() |
| 646 | // CHECK-LABEL: define swiftcc void @take_struct_i3(i64, i32) |
| 647 | |
| 648 | typedef struct { |
| 649 | int i0; |
| 650 | int i1; |
| 651 | int i2; |
| 652 | int i3; |
| 653 | } struct_i4; |
| 654 | TEST(struct_i4) |
| 655 | // CHECK-LABEL: define swiftcc { i64, i64 } @return_struct_i4() |
| 656 | // CHECK-LABEL: define swiftcc void @take_struct_i4(i64, i64) |
| 657 | |
| 658 | typedef struct { |
| 659 | long long l0; |
| 660 | } struct_l1; |
| 661 | TEST(struct_l1) |
| 662 | // CHECK-LABEL: define swiftcc i64 @return_struct_l1() |
| 663 | // CHECK-LABEL: define swiftcc void @take_struct_l1(i64) |
| 664 | |
| 665 | typedef struct { |
| 666 | long long l0; |
| 667 | long long l1; |
| 668 | } struct_l2; |
| 669 | TEST(struct_l2) |
| 670 | // CHECK-LABEL: define swiftcc { i64, i64 } @return_struct_l2() |
| 671 | // CHECK-LABEL: define swiftcc void @take_struct_l2(i64, i64) |
| 672 | |
| 673 | typedef struct { |
| 674 | long long l0; |
| 675 | long long l1; |
| 676 | long long l2; |
| 677 | } struct_l3; |
| 678 | TEST(struct_l3) |
| 679 | // CHECK-LABEL: define swiftcc { i64, i64, i64 } @return_struct_l3() |
| 680 | // CHECK-LABEL: define swiftcc void @take_struct_l3(i64, i64, i64) |
| 681 | |
| 682 | typedef struct { |
| 683 | long long l0; |
| 684 | long long l1; |
| 685 | long long l2; |
| 686 | long long l3; |
| 687 | } struct_l4; |
| 688 | TEST(struct_l4) |
| 689 | // CHECK-LABEL: define swiftcc { i64, i64, i64, i64 } @return_struct_l4() |
| 690 | // CHECK-LABEL: define swiftcc void @take_struct_l4(i64, i64, i64, i64) |
| 691 | |
| 692 | typedef struct { |
| 693 | long long l0; |
| 694 | long long l1; |
| 695 | long long l2; |
| 696 | long long l3; |
| 697 | long long l4; |
| 698 | } struct_l5; |
| 699 | TEST(struct_l5) |
| 700 | // CHECK: define swiftcc void @return_struct_l5([[STRUCT5:%.*]]* noalias sret |
| 701 | // CHECK: define swiftcc void @take_struct_l5([[STRUCT5]]* |
Arnold Schwaighofer | 3d01ad1 | 2016-10-13 19:19:37 +0000 | [diff] [blame] | 702 | |
| 703 | |
| 704 | // Don't crash. |
| 705 | typedef union { |
| 706 | int4 v[2]; |
| 707 | struct { |
| 708 | int LSW; |
| 709 | int d7; |
| 710 | int d6; |
| 711 | int d5; |
| 712 | int d4; |
| 713 | int d3; |
| 714 | int d2; |
| 715 | int MSW; |
| 716 | } s; |
| 717 | } union_het_vecint; |
| 718 | TEST(union_het_vecint) |
| 719 | // CHECK: define swiftcc void @return_union_het_vecint([[UNION:%.*]]* noalias sret |
| 720 | // CHECK: define swiftcc void @take_union_het_vecint([[UNION]]* |