blob: f8656f0fd3393df36b87602fe44de6581dd8492b [file] [log] [blame]
JF Bastien1b222ce2018-08-07 04:03:03 +00001// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks %s -emit-llvm -o - | FileCheck %s
JF Bastienc70f65e2018-08-07 03:12:52 +00002
3template<typename T> void used(T &) noexcept;
4
5#define TEST_UNINIT(NAME, TYPE) \
6 using type_##NAME = TYPE; \
7 void test_##NAME##_uninit() { \
8 type_##NAME uninit; \
9 used(uninit); \
10 }
11
12// Value initialization on scalars, aggregate initialization on aggregates.
13#define TEST_BRACES(NAME, TYPE) \
14 using type_##NAME = TYPE; \
15 void test_##NAME##_braces() { \
16 type_##NAME braces = {}; \
17 used(braces); \
18 }
19
20#define TEST_CUSTOM(NAME, TYPE, ...) \
21 using type_##NAME = TYPE; \
22 void test_##NAME##_custom() { \
23 type_##NAME custom __VA_ARGS__; \
24 used(custom); \
25 }
26
27struct empty {};
28struct small { char c; };
29struct smallinit { char c = 42; };
30struct smallpartinit { char c = 42, d; };
31struct nullinit { char* null = nullptr; };
32struct padded { char c; int i; };
33struct paddednullinit { char c = 0; int i = 0; };
34struct bitfield { int i : 4; int j : 2; };
35struct bitfieldaligned { int i : 4; int : 0; int j : 2; };
36struct big { unsigned a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; };
37struct arraytail { int i; int arr[]; };
38struct tailpad { short s; char c; };
39struct notlockfree { long long a[4]; };
40struct semivolatile { int i; volatile int vi; };
41struct semivolatileinit { int i = 0x11111111; volatile int vi = 0x11111111; };
42struct base { virtual ~base(); };
43struct derived : public base {};
44struct virtualderived : public virtual base, public virtual derived {};
45union matching { int i; float f; };
46union matchingreverse { float f; int i; };
47union unmatched { char c; int i; };
48union unmatchedreverse { int i; char c; };
49union unmatchedfp { float f; double d; };
50enum emptyenum {};
51enum smallenum { VALUE };
52
53extern "C" {
54
55TEST_UNINIT(char, char);
56// CHECK-LABEL: @test_char_uninit()
57// CHECK: %uninit = alloca i8, align 1
58// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
59
60TEST_BRACES(char, char);
61// CHECK-LABEL: @test_char_braces()
62// CHECK: %braces = alloca i8, align 1
63// CHECK-NEXT: store i8 0, i8* %braces, align 1
64// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
65
66TEST_UNINIT(uchar, unsigned char);
67// CHECK-LABEL: @test_uchar_uninit()
68// CHECK: %uninit = alloca i8, align 1
69// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
70
71TEST_BRACES(uchar, unsigned char);
72// CHECK-LABEL: @test_uchar_braces()
73// CHECK: %braces = alloca i8, align 1
74// CHECK-NEXT: store i8 0, i8* %braces, align 1
75// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
76
77TEST_UNINIT(schar, signed char);
78// CHECK-LABEL: @test_schar_uninit()
79// CHECK: %uninit = alloca i8, align 1
80// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
81
82TEST_BRACES(schar, signed char);
83// CHECK-LABEL: @test_schar_braces()
84// CHECK: %braces = alloca i8, align 1
85// CHECK-NEXT: store i8 0, i8* %braces, align 1
86// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
87
88TEST_UNINIT(wchar_t, wchar_t);
89// CHECK-LABEL: @test_wchar_t_uninit()
90// CHECK: %uninit = alloca i32, align 4
91// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
92
93TEST_BRACES(wchar_t, wchar_t);
94// CHECK-LABEL: @test_wchar_t_braces()
95// CHECK: %braces = alloca i32, align 4
96// CHECK-NEXT: store i32 0, i32* %braces, align 4
97// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
98
99TEST_UNINIT(short, short);
100// CHECK-LABEL: @test_short_uninit()
101// CHECK: %uninit = alloca i16, align 2
102// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
103
104TEST_BRACES(short, short);
105// CHECK-LABEL: @test_short_braces()
106// CHECK: %braces = alloca i16, align 2
107// CHECK-NEXT: store i16 0, i16* %braces, align 2
108// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
109
110TEST_UNINIT(ushort, unsigned short);
111// CHECK-LABEL: @test_ushort_uninit()
112// CHECK: %uninit = alloca i16, align 2
113// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
114
115TEST_BRACES(ushort, unsigned short);
116// CHECK-LABEL: @test_ushort_braces()
117// CHECK: %braces = alloca i16, align 2
118// CHECK-NEXT: store i16 0, i16* %braces, align 2
119// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
120
121TEST_UNINIT(int, int);
122// CHECK-LABEL: @test_int_uninit()
123// CHECK: %uninit = alloca i32, align 4
124// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
125
126TEST_BRACES(int, int);
127// CHECK-LABEL: @test_int_braces()
128// CHECK: %braces = alloca i32, align 4
129// CHECK-NEXT: store i32 0, i32* %braces, align 4
130// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
131
132TEST_UNINIT(unsigned, unsigned);
133// CHECK-LABEL: @test_unsigned_uninit()
134// CHECK: %uninit = alloca i32, align 4
135// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
136
137TEST_BRACES(unsigned, unsigned);
138// CHECK-LABEL: @test_unsigned_braces()
139// CHECK: %braces = alloca i32, align 4
140// CHECK-NEXT: store i32 0, i32* %braces, align 4
141// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
142
143TEST_UNINIT(long, long);
144// CHECK-LABEL: @test_long_uninit()
145// CHECK: %uninit = alloca i64, align 8
146// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
147
148TEST_BRACES(long, long);
149// CHECK-LABEL: @test_long_braces()
150// CHECK: %braces = alloca i64, align 8
151// CHECK-NEXT: store i64 0, i64* %braces, align 8
152// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
153
154TEST_UNINIT(ulong, unsigned long);
155// CHECK-LABEL: @test_ulong_uninit()
156// CHECK: %uninit = alloca i64, align 8
157// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
158
159TEST_BRACES(ulong, unsigned long);
160// CHECK-LABEL: @test_ulong_braces()
161// CHECK: %braces = alloca i64, align 8
162// CHECK-NEXT: store i64 0, i64* %braces, align 8
163// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
164
165TEST_UNINIT(longlong, long long);
166// CHECK-LABEL: @test_longlong_uninit()
167// CHECK: %uninit = alloca i64, align 8
168// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
169
170TEST_BRACES(longlong, long long);
171// CHECK-LABEL: @test_longlong_braces()
172// CHECK: %braces = alloca i64, align 8
173// CHECK-NEXT: store i64 0, i64* %braces, align 8
174// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
175
176TEST_UNINIT(ulonglong, unsigned long long);
177// CHECK-LABEL: @test_ulonglong_uninit()
178// CHECK: %uninit = alloca i64, align 8
179// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
180
181TEST_BRACES(ulonglong, unsigned long long);
182// CHECK-LABEL: @test_ulonglong_braces()
183// CHECK: %braces = alloca i64, align 8
184// CHECK-NEXT: store i64 0, i64* %braces, align 8
185// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
186
187TEST_UNINIT(int128, __int128);
188// CHECK-LABEL: @test_int128_uninit()
189// CHECK: %uninit = alloca i128, align 16
190// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
191
192TEST_BRACES(int128, __int128);
193// CHECK-LABEL: @test_int128_braces()
194// CHECK: %braces = alloca i128, align 16
195// CHECK-NEXT: store i128 0, i128* %braces, align 16
196// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
197
198TEST_UNINIT(uint128, unsigned __int128);
199// CHECK-LABEL: @test_uint128_uninit()
200// CHECK: %uninit = alloca i128, align 16
201// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
202
203TEST_BRACES(uint128, unsigned __int128);
204// CHECK-LABEL: @test_uint128_braces()
205// CHECK: %braces = alloca i128, align 16
206// CHECK-NEXT: store i128 0, i128* %braces, align 16
207// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
208
209
210TEST_UNINIT(fp16, __fp16);
211// CHECK-LABEL: @test_fp16_uninit()
212// CHECK: %uninit = alloca half, align 2
213// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
214
215TEST_BRACES(fp16, __fp16);
216// CHECK-LABEL: @test_fp16_braces()
217// CHECK: %braces = alloca half, align 2
218// CHECK-NEXT: store half 0xH0000, half* %braces, align 2
219// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
220
221TEST_UNINIT(float, float);
222// CHECK-LABEL: @test_float_uninit()
223// CHECK: %uninit = alloca float, align 4
224// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
225
226TEST_BRACES(float, float);
227// CHECK-LABEL: @test_float_braces()
228// CHECK: %braces = alloca float, align 4
229// CHECK-NEXT: store float 0.000000e+00, float* %braces, align 4
230// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
231
232TEST_UNINIT(double, double);
233// CHECK-LABEL: @test_double_uninit()
234// CHECK: %uninit = alloca double, align 8
235// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
236
237TEST_BRACES(double, double);
238// CHECK-LABEL: @test_double_braces()
239// CHECK: %braces = alloca double, align 8
240// CHECK-NEXT: store double 0.000000e+00, double* %braces, align 8
241// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
242
243TEST_UNINIT(longdouble, long double);
244// CHECK-LABEL: @test_longdouble_uninit()
245// CHECK: %uninit = alloca x86_fp80, align 16
246// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
247
248TEST_BRACES(longdouble, long double);
249// CHECK-LABEL: @test_longdouble_braces()
250// CHECK: %braces = alloca x86_fp80, align 16
251// CHECK-NEXT: store x86_fp80 0xK00000000000000000000, x86_fp80* %braces, align 16
252// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
253
254
255TEST_UNINIT(intptr, int*);
256// CHECK-LABEL: @test_intptr_uninit()
257// CHECK: %uninit = alloca i32*, align 8
258// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
259
260TEST_BRACES(intptr, int*);
261// CHECK-LABEL: @test_intptr_braces()
262// CHECK: %braces = alloca i32*, align 8
263// CHECK-NEXT: store i32* null, i32** %braces, align 8
264// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
265
266TEST_UNINIT(intptrptr, int**);
267// CHECK-LABEL: @test_intptrptr_uninit()
268// CHECK: %uninit = alloca i32**, align 8
269// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
270
271TEST_BRACES(intptrptr, int**);
272// CHECK-LABEL: @test_intptrptr_braces()
273// CHECK: %braces = alloca i32**, align 8
274// CHECK-NEXT: store i32** null, i32*** %braces, align 8
275// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
276
277TEST_UNINIT(function, void(*)());
278// CHECK-LABEL: @test_function_uninit()
279// CHECK: %uninit = alloca void ()*, align 8
280// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
281
282TEST_BRACES(function, void(*)());
283// CHECK-LABEL: @test_function_braces()
284// CHECK: %braces = alloca void ()*, align 8
285// CHECK-NEXT: store void ()* null, void ()** %braces, align 8
286// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
287
288TEST_UNINIT(bool, bool);
289// CHECK-LABEL: @test_bool_uninit()
290// CHECK: %uninit = alloca i8, align 1
291// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
292
293TEST_BRACES(bool, bool);
294// CHECK-LABEL: @test_bool_braces()
295// CHECK: %braces = alloca i8, align 1
296// CHECK-NEXT: store i8 0, i8* %braces, align 1
297// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
298
299
300TEST_UNINIT(empty, empty);
301// CHECK-LABEL: @test_empty_uninit()
302// CHECK: %uninit = alloca %struct.empty, align 1
303// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
304
305TEST_BRACES(empty, empty);
306// CHECK-LABEL: @test_empty_braces()
307// CHECK: %braces = alloca %struct.empty, align 1
308// CHECK-NEXT: bitcast
309// CHECK-NEXT: call void @llvm.memcpy
310// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
311
312TEST_UNINIT(small, small);
313// CHECK-LABEL: @test_small_uninit()
314// CHECK: %uninit = alloca %struct.small, align 1
315// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
316
317TEST_BRACES(small, small);
318// CHECK-LABEL: @test_small_braces()
319// CHECK: %braces = alloca %struct.small, align 1
320// CHECK-NEXT: bitcast
321// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 1 %{{.*}}, i8 0, i64 1, i1 false)
322// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
323
324 TEST_CUSTOM(small, small, { 42 });
325// CHECK-LABEL: @test_small_custom()
326// CHECK: %custom = alloca %struct.small, align 1
327// CHECK-NEXT: bitcast
328// CHECK-NEXT: call void @llvm.memcpy
329// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
330
331TEST_UNINIT(smallinit, smallinit);
332// CHECK-LABEL: @test_smallinit_uninit()
333// CHECK: %uninit = alloca %struct.smallinit, align 1
334// CHECK-NEXT: call void @{{.*}}smallinit{{.*}}%uninit)
335// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
336
337TEST_BRACES(smallinit, smallinit);
338// CHECK-LABEL: @test_smallinit_braces()
339// CHECK: %braces = alloca %struct.smallinit, align 1
340// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallinit, %struct.smallinit* %braces, i32 0, i32 0
341// CHECK-NEXT: store i8 42, i8* %[[C]], align 1
342// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
343
344TEST_CUSTOM(smallinit, smallinit, { 100 });
345// CHECK-LABEL: @test_smallinit_custom()
346// CHECK: %custom = alloca %struct.smallinit, align 1
347// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallinit, %struct.smallinit* %custom, i32 0, i32 0
348// CHECK-NEXT: store i8 100, i8* %[[C]], align 1
349// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
350
351TEST_UNINIT(smallpartinit, smallpartinit);
352// CHECK-LABEL: @test_smallpartinit_uninit()
353// CHECK: %uninit = alloca %struct.smallpartinit, align 1
354// CHECK-NEXT: call void @{{.*}}smallpartinit{{.*}}%uninit)
355// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
356
357TEST_BRACES(smallpartinit, smallpartinit);
358// CHECK-LABEL: @test_smallpartinit_braces()
359// CHECK: %braces = alloca %struct.smallpartinit, align 1
360// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %braces, i32 0, i32 0
361// CHECK-NEXT: store i8 42, i8* %[[C]], align 1
362// CHECK-NEXT: %[[D:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %braces, i32 0, i32 1
363// CHECK-NEXT: store i8 0, i8* %[[D]], align 1
364// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
365
366TEST_CUSTOM(smallpartinit, smallpartinit, { 100, 42 });
367// CHECK-LABEL: @test_smallpartinit_custom()
368// CHECK: %custom = alloca %struct.smallpartinit, align 1
369// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %custom, i32 0, i32 0
370// CHECK-NEXT: store i8 100, i8* %[[C]], align 1
371// CHECK-NEXT: %[[D:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %custom, i32 0, i32 1
372// CHECK-NEXT: store i8 42, i8* %[[D]], align 1
373// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
374
375TEST_UNINIT(nullinit, nullinit);
376// CHECK-LABEL: @test_nullinit_uninit()
377// CHECK: %uninit = alloca %struct.nullinit, align 8
378// CHECK-NEXT: call void @{{.*}}nullinit{{.*}}%uninit)
379// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
380
381TEST_BRACES(nullinit, nullinit);
382// CHECK-LABEL: @test_nullinit_braces()
383// CHECK: %braces = alloca %struct.nullinit, align 8
384// CHECK-NEXT: %[[N:[^ ]*]] = getelementptr inbounds %struct.nullinit, %struct.nullinit* %braces, i32 0, i32 0
385// CHECK-NEXT: store i8* null, i8** %[[N]], align 8
386// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
387
388TEST_CUSTOM(nullinit, nullinit, { (char*)"derp" });
389// CHECK-LABEL: @test_nullinit_custom()
390// CHECK: %custom = alloca %struct.nullinit, align 8
391// CHECK-NEXT: %[[N:[^ ]*]] = getelementptr inbounds %struct.nullinit, %struct.nullinit* %custom, i32 0, i32 0
392// CHECK-NEXT: store i8* getelementptr inbounds {{.*}}, i8** %[[N]], align 8
393// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
394
395TEST_UNINIT(padded, padded);
396// CHECK-LABEL: @test_padded_uninit()
397// CHECK: %uninit = alloca %struct.padded, align 4
398// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
399
400TEST_BRACES(padded, padded);
401// CHECK-LABEL: @test_padded_braces()
402// CHECK: %braces = alloca %struct.padded, align 4
403// CHECK-NEXT: bitcast
404// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 8, i1 false)
405// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
406
407TEST_CUSTOM(padded, padded, { 42, 13371337 });
408// CHECK-LABEL: @test_padded_custom()
409// CHECK: %custom = alloca %struct.padded, align 4
410// CHECK-NEXT: bitcast
411// CHECK-NEXT: call void @llvm.memcpy
412// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
413
414TEST_UNINIT(paddednullinit, paddednullinit);
415// CHECK-LABEL: @test_paddednullinit_uninit()
416// CHECK: %uninit = alloca %struct.paddednullinit, align 4
417// CHECK-NEXT: call void @{{.*}}paddednullinit{{.*}}%uninit)
418// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
419
420TEST_BRACES(paddednullinit, paddednullinit);
421// CHECK-LABEL: @test_paddednullinit_braces()
422// CHECK: %braces = alloca %struct.paddednullinit, align 4
423// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %braces, i32 0, i32 0
424// CHECK-NEXT: store i8 0, i8* %[[C]], align 4
425// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %braces, i32 0, i32 1
426// CHECK-NEXT: store i32 0, i32* %[[I]], align 4
427// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
428
429TEST_CUSTOM(paddednullinit, paddednullinit, { 42, 13371337 });
430// CHECK-LABEL: @test_paddednullinit_custom()
431// CHECK: %custom = alloca %struct.paddednullinit, align 4
432// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %custom, i32 0, i32 0
433// CHECK-NEXT: store i8 42, i8* %[[C]], align 4
434// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %custom, i32 0, i32 1
435// CHECK-NEXT: store i32 13371337, i32* %[[I]], align 4
436// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
437
438TEST_UNINIT(bitfield, bitfield);
439// CHECK-LABEL: @test_bitfield_uninit()
440// CHECK: %uninit = alloca %struct.bitfield, align 4
441// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
442
443TEST_BRACES(bitfield, bitfield);
444// CHECK-LABEL: @test_bitfield_braces()
445// CHECK: %braces = alloca %struct.bitfield, align 4
446// CHECK-NEXT: bitcast
447// CHECK-NEXT: call void @llvm.memcpy
448// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
449
450TEST_CUSTOM(bitfield, bitfield, { 4, 1 });
451// CHECK-LABEL: @test_bitfield_custom()
452// CHECK: %custom = alloca %struct.bitfield, align 4
453// CHECK-NEXT: bitcast
454// CHECK-NEXT: call void @llvm.memcpy
455// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
456
457TEST_UNINIT(bitfieldaligned, bitfieldaligned);
458// CHECK-LABEL: @test_bitfieldaligned_uninit()
459// CHECK: %uninit = alloca %struct.bitfieldaligned, align 4
460// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
461
462TEST_BRACES(bitfieldaligned, bitfieldaligned);
463// CHECK-LABEL: @test_bitfieldaligned_braces()
464// CHECK: %braces = alloca %struct.bitfieldaligned, align 4
465// CHECK-NEXT: bitcast
466// CHECK-NEXT: call void @llvm.memcpy
467// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
468
469TEST_CUSTOM(bitfieldaligned, bitfieldaligned, { 4, 1 });
470// CHECK-LABEL: @test_bitfieldaligned_custom()
471// CHECK: %custom = alloca %struct.bitfieldaligned, align 4
472// CHECK-NEXT: bitcast
473// CHECK-NEXT: call void @llvm.memcpy
474// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
475
476TEST_UNINIT(big, big);
477// CHECK-LABEL: @test_big_uninit()
478// CHECK: %uninit = alloca %struct.big, align 4
479// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
480
481TEST_BRACES(big, big);
482// CHECK-LABEL: @test_big_braces()
483// CHECK: %braces = alloca %struct.big, align 4
484// CHECK-NEXT: bitcast
485// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 104, i1 false)
486// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
487
488TEST_CUSTOM(big, big, { 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA, 0xAAAAAAAA });
489// CHECK-LABEL: @test_big_custom()
490// CHECK: %custom = alloca %struct.big, align 4
491// CHECK-NEXT: bitcast
492// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 -86, i64 104, i1 false)
493// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
494
495TEST_UNINIT(arraytail, arraytail);
496// CHECK-LABEL: @test_arraytail_uninit()
497// CHECK: %uninit = alloca %struct.arraytail, align 4
498// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
499
500TEST_BRACES(arraytail, arraytail);
501// CHECK-LABEL: @test_arraytail_braces()
502// CHECK: %braces = alloca %struct.arraytail, align 4
503// CHECK-NEXT: bitcast
504// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 4, i1 false)
505// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
506
507TEST_CUSTOM(arraytail, arraytail, { 0xdead });
508// CHECK-LABEL: @test_arraytail_custom()
509// CHECK: %custom = alloca %struct.arraytail, align 4
510// CHECK-NEXT: bitcast
511// CHECK-NEXT: call void @llvm.memcpy
512// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
513
514
515TEST_UNINIT(int0, int[0]);
516// CHECK-LABEL: @test_int0_uninit()
517// CHECK: %uninit = alloca [0 x i32], align 4
518// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
519
520TEST_BRACES(int0, int[0]);
521// CHECK-LABEL: @test_int0_braces()
522// CHECK: %braces = alloca [0 x i32], align 4
523// CHECK-NEXT: bitcast
524// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 0, i1 false)
525// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
526
527TEST_UNINIT(int1, int[1]);
528// CHECK-LABEL: @test_int1_uninit()
529// CHECK: %uninit = alloca [1 x i32], align 4
530// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
531
532TEST_BRACES(int1, int[1]);
533// CHECK-LABEL: @test_int1_braces()
534// CHECK: %braces = alloca [1 x i32], align 4
535// CHECK-NEXT: bitcast
536// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 4, i1 false)
537// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
538
539TEST_CUSTOM(int1, int[1], { 0x33333333 });
540// CHECK-LABEL: @test_int1_custom()
541// CHECK: %custom = alloca [1 x i32], align 4
542// CHECK-NEXT: bitcast
543// CHECK-NEXT: call void @llvm.memcpy
544// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
545
546TEST_UNINIT(int64, int[64]);
547// CHECK-LABEL: @test_int64_uninit()
548// CHECK: %uninit = alloca [64 x i32], align 16
549// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
550
551TEST_BRACES(int64, int[64]);
552// CHECK-LABEL: @test_int64_braces()
553// CHECK: %braces = alloca [64 x i32], align 16
554// CHECK-NEXT: bitcast
555// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 16 %{{.*}}, i8 0, i64 256, i1 false)
556// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
557
558TEST_CUSTOM(int64, int[64], = { 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111 });
559// CHECK-LABEL: @test_int64_custom()
560// CHECK: %custom = alloca [64 x i32], align 16
561// CHECK-NEXT: bitcast
562// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 16 %{{.*}}, i8 17, i64 256, i1 false)
563// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
564
565TEST_UNINIT(bool4, bool[4]);
566// CHECK-LABEL: @test_bool4_uninit()
567// CHECK: %uninit = alloca [4 x i8], align 1
568// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
569
570TEST_BRACES(bool4, bool[4]);
571// CHECK-LABEL: @test_bool4_braces()
572// CHECK: %braces = alloca [4 x i8], align 1
573// CHECK-NEXT: bitcast
574// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 1 %{{.*}}, i8 0, i64 4, i1 false)
575// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
576
577TEST_CUSTOM(bool4, bool[4], { true, true, true, true });
578// CHECK-LABEL: @test_bool4_custom()
579// CHECK: %custom = alloca [4 x i8], align 1
580// CHECK-NEXT: bitcast
581// CHECK-NEXT: call void @llvm.memcpy
582// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
583
584TEST_UNINIT(intptr4, int*[4]);
585// CHECK-LABEL: @test_intptr4_uninit()
586// CHECK: %uninit = alloca [4 x i32*], align 16
587// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
588
589TEST_BRACES(intptr4, int*[4]);
590// CHECK-LABEL: @test_intptr4_braces()
591// CHECK: %braces = alloca [4 x i32*], align 16
592// CHECK-NEXT: bitcast
593// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 16 %{{.*}}, i8 0, i64 32, i1 false)
594// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
595
596 TEST_CUSTOM(intptr4, int*[4], = { (int*)0x22222222, (int*)0x22222222, (int*)0x22222222, (int*)0x22222222 });
597// CHECK-LABEL: @test_intptr4_custom()
598// CHECK: %custom = alloca [4 x i32*], align 16
599// CHECK-NEXT: bitcast
600// CHECK-NEXT: call void @llvm.memcpy
601// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
602
603TEST_UNINIT(tailpad4, tailpad[4]);
604// CHECK-LABEL: @test_tailpad4_uninit()
605// CHECK: %uninit = alloca [4 x %struct.tailpad], align 16
606// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
607
608TEST_BRACES(tailpad4, tailpad[4]);
609// CHECK-LABEL: @test_tailpad4_braces()
610// CHECK: %braces = alloca [4 x %struct.tailpad], align 16
611// CHECK-NEXT: bitcast
612// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 16 %{{.*}}, i8 0, i64 16, i1 false)
613// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
614
615TEST_CUSTOM(tailpad4, tailpad[4], { {17, 1}, {17, 1}, {17, 1}, {17, 1} });
616// CHECK-LABEL: @test_tailpad4_custom()
617// CHECK: %custom = alloca [4 x %struct.tailpad], align 16
618// CHECK-NEXT: bitcast
619// CHECK-NEXT: call void @llvm.memcpy
620// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
621
622
623TEST_UNINIT(atomicbool, _Atomic(bool));
624// CHECK-LABEL: @test_atomicbool_uninit()
625// CHECK: %uninit = alloca i8, align 1
626// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
627
628TEST_UNINIT(atomicint, _Atomic(int));
629// CHECK-LABEL: @test_atomicint_uninit()
630// CHECK: %uninit = alloca i32, align 4
631// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
632
633TEST_UNINIT(atomicdouble, _Atomic(double));
634// CHECK-LABEL: @test_atomicdouble_uninit()
635// CHECK: %uninit = alloca double, align 8
636// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
637
638TEST_UNINIT(atomicnotlockfree, _Atomic(notlockfree));
639// CHECK-LABEL: @test_atomicnotlockfree_uninit()
640// CHECK: %uninit = alloca %struct.notlockfree, align 8
641// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
642
643TEST_UNINIT(atomicpadded, _Atomic(padded));
644// CHECK-LABEL: @test_atomicpadded_uninit()
645// CHECK: %uninit = alloca %struct.padded, align 8
646// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
647
648TEST_UNINIT(atomictailpad, _Atomic(tailpad));
649// CHECK-LABEL: @test_atomictailpad_uninit()
650// CHECK: %uninit = alloca %struct.tailpad, align 4
651// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
652
653
654TEST_UNINIT(complexfloat, _Complex float);
655// CHECK-LABEL: @test_complexfloat_uninit()
656// CHECK: %uninit = alloca { float, float }, align 4
657// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
658
659TEST_BRACES(complexfloat, _Complex float);
660// CHECK-LABEL: @test_complexfloat_braces()
661// CHECK: %braces = alloca { float, float }, align 4
662// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %braces, i32 0, i32 0
663// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %braces, i32 0, i32 1
664// CHECK-NEXT: store float 0.000000e+00, float* %[[R]], align 4
665// CHECK-NEXT: store float 0.000000e+00, float* %[[I]], align 4
666// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
667
668TEST_CUSTOM(complexfloat, _Complex float, { 3.1415926535897932384626433, 3.1415926535897932384626433 });
669// CHECK-LABEL: @test_complexfloat_custom()
670// CHECK: %custom = alloca { float, float }, align 4
671// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %custom, i32 0, i32 0
672// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %custom, i32 0, i32 1
673// CHECK-NEXT: store float 0x400921FB60000000, float* %[[R]], align 4
674// CHECK-NEXT: store float 0x400921FB60000000, float* %[[I]], align 4
675// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
676
677TEST_UNINIT(complexdouble, _Complex double);
678// CHECK-LABEL: @test_complexdouble_uninit()
679// CHECK: %uninit = alloca { double, double }, align 8
680// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
681
682TEST_BRACES(complexdouble, _Complex double);
683// CHECK-LABEL: @test_complexdouble_braces()
684// CHECK: %braces = alloca { double, double }, align 8
685// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %braces, i32 0, i32 0
686// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %braces, i32 0, i32 1
687// CHECK-NEXT: store double 0.000000e+00, double* %[[R]], align 8
688// CHECK-NEXT: store double 0.000000e+00, double* %[[I]], align 8
689// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
690
691TEST_CUSTOM(complexdouble, _Complex double, { 3.1415926535897932384626433, 3.1415926535897932384626433 });
692// CHECK-LABEL: @test_complexdouble_custom()
693// CHECK: %custom = alloca { double, double }, align 8
694// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %custom, i32 0, i32 0
695// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %custom, i32 0, i32 1
696// CHECK-NEXT: store double 0x400921FB54442D18, double* %[[R]], align 8
697// CHECK-NEXT: store double 0x400921FB54442D18, double* %[[I]], align 8
698// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
699
700
701TEST_UNINIT(volatileint, volatile int);
702// CHECK-LABEL: @test_volatileint_uninit()
703// CHECK: %uninit = alloca i32, align 4
704// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
705
706TEST_BRACES(volatileint, volatile int);
707// CHECK-LABEL: @test_volatileint_braces()
708// CHECK: %braces = alloca i32, align 4
709// CHECK-NEXT: store volatile i32 0, i32* %braces, align 4
710// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
711
712TEST_UNINIT(semivolatile, semivolatile);
713// CHECK-LABEL: @test_semivolatile_uninit()
714// CHECK: %uninit = alloca %struct.semivolatile, align 4
715// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
716
717TEST_BRACES(semivolatile, semivolatile);
718// CHECK-LABEL: @test_semivolatile_braces()
719// CHECK: %braces = alloca %struct.semivolatile, align 4
720// CHECK-NEXT: bitcast
721// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 8, i1 false)
722// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
723
724TEST_CUSTOM(semivolatile, semivolatile, { 0x44444444, 0x44444444 });
725// CHECK-LABEL: @test_semivolatile_custom()
726// CHECK: %custom = alloca %struct.semivolatile, align 4
727// CHECK-NEXT: bitcast
728// CHECK-NEXT: call void @llvm.memcpy
729// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
730
731TEST_UNINIT(semivolatileinit, semivolatileinit);
732// CHECK-LABEL: @test_semivolatileinit_uninit()
733// CHECK: %uninit = alloca %struct.semivolatileinit, align 4
734// CHECK-NEXT: call void @{{.*}}semivolatileinit{{.*}}%uninit)
735// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
736
737TEST_BRACES(semivolatileinit, semivolatileinit);
738// CHECK-LABEL: @test_semivolatileinit_braces()
739// CHECK: %braces = alloca %struct.semivolatileinit, align 4
740// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %braces, i32 0, i32 0
741// CHECK-NEXT: store i32 286331153, i32* %[[I]], align 4
742// CHECK-NEXT: %[[VI:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %braces, i32 0, i32 1
743// CHECK-NEXT: store volatile i32 286331153, i32* %[[VI]], align 4
744// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
745
746TEST_CUSTOM(semivolatileinit, semivolatileinit, { 0x44444444, 0x44444444 });
747// CHECK-LABEL: @test_semivolatileinit_custom()
748// CHECK: %custom = alloca %struct.semivolatileinit, align 4
749// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %custom, i32 0, i32 0
750// CHECK-NEXT: store i32 1145324612, i32* %[[I]], align 4
751// CHECK-NEXT: %[[VI:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %custom, i32 0, i32 1
752// CHECK-NEXT: store volatile i32 1145324612, i32* %[[VI]], align 4
753// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
754
755
756TEST_UNINIT(base, base);
757// CHECK-LABEL: @test_base_uninit()
758// CHECK: %uninit = alloca %struct.base, align 8
759// CHECK-NEXT: call void @{{.*}}base{{.*}}%uninit)
760// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
761
762TEST_BRACES(base, base);
763// CHECK-LABEL: @test_base_braces()
764// CHECK: %braces = alloca %struct.base, align 8
765// CHECK-NEXT: bitcast
766// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 8 %{{.*}}, i8 0, i64 8, i1 false)
767// CHECK-NEXT: call void @{{.*}}base{{.*}}%braces)
768// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
769
770TEST_UNINIT(derived, derived);
771// CHECK-LABEL: @test_derived_uninit()
772// CHECK: %uninit = alloca %struct.derived, align 8
773// CHECK-NEXT: call void @{{.*}}derived{{.*}}%uninit)
774// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
775
776TEST_BRACES(derived, derived);
777// CHECK-LABEL: @test_derived_braces()
778// CHECK: %braces = alloca %struct.derived, align 8
779// CHECK-NEXT: bitcast
780// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 8 %{{.*}}, i8 0, i64 8, i1 false)
781// CHECK-NEXT: call void @{{.*}}derived{{.*}}%braces)
782// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
783
784TEST_UNINIT(virtualderived, virtualderived);
785// CHECK-LABEL: @test_virtualderived_uninit()
786// CHECK: %uninit = alloca %struct.virtualderived, align 8
787// CHECK-NEXT: call void @{{.*}}virtualderived{{.*}}%uninit)
788// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
789
790TEST_BRACES(virtualderived, virtualderived);
791// CHECK-LABEL: @test_virtualderived_braces()
792// CHECK: %braces = alloca %struct.virtualderived, align 8
793// CHECK-NEXT: bitcast
794// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 8 %{{.*}}, i8 0, i64 16, i1 false)
795// CHECK-NEXT: call void @{{.*}}virtualderived{{.*}}%braces)
796// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
797
798
799TEST_UNINIT(matching, matching);
800// CHECK-LABEL: @test_matching_uninit()
801// CHECK: %uninit = alloca %union.matching, align 4
802// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
803
804TEST_BRACES(matching, matching);
805// CHECK-LABEL: @test_matching_braces()
806// CHECK: %braces = alloca %union.matching, align 4
807// CHECK-NEXT: bitcast
808// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 4, i1 false)
809// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
810
811TEST_CUSTOM(matching, matching, { .f = 0xf00f });
812// CHECK-LABEL: @test_matching_custom()
813// CHECK: %custom = alloca %union.matching, align 4
814// CHECK-NEXT: bitcast
815// CHECK-NEXT: call void @llvm.memcpy
816// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
817
818TEST_UNINIT(matchingreverse, matchingreverse);
819// CHECK-LABEL: @test_matchingreverse_uninit()
820// CHECK: %uninit = alloca %union.matchingreverse, align 4
821// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
822
823TEST_BRACES(matchingreverse, matchingreverse);
824// CHECK-LABEL: @test_matchingreverse_braces()
825// CHECK: %braces = alloca %union.matchingreverse, align 4
826// CHECK-NEXT: bitcast
827// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 4, i1 false)
828// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
829
830TEST_CUSTOM(matchingreverse, matchingreverse, { .i = 0xf00f });
831// CHECK-LABEL: @test_matchingreverse_custom()
832// CHECK: %custom = alloca %union.matchingreverse, align 4
833// CHECK-NEXT: bitcast
834// CHECK-NEXT: call void @llvm.memcpy
835// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
836
837TEST_UNINIT(unmatched, unmatched);
838// CHECK-LABEL: @test_unmatched_uninit()
839// CHECK: %uninit = alloca %union.unmatched, align 4
840// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
841
842TEST_BRACES(unmatched, unmatched);
843// CHECK-LABEL: @test_unmatched_braces()
844// CHECK: %braces = alloca %union.unmatched, align 4
845// CHECK-NEXT: bitcast
846// CHECK-NEXT: call void @llvm.memcpy
847// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
848
849TEST_CUSTOM(unmatched, unmatched, { .i = 0x3badbeef });
850// CHECK-LABEL: @test_unmatched_custom()
851// CHECK: %custom = alloca %union.unmatched, align 4
852// CHECK-NEXT: bitcast
853// CHECK-NEXT: call void @llvm.memcpy
854// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
855
856TEST_UNINIT(unmatchedreverse, unmatchedreverse);
857// CHECK-LABEL: @test_unmatchedreverse_uninit()
858// CHECK: %uninit = alloca %union.unmatchedreverse, align 4
859// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
860
861TEST_BRACES(unmatchedreverse, unmatchedreverse);
862// CHECK-LABEL: @test_unmatchedreverse_braces()
863// CHECK: %braces = alloca %union.unmatchedreverse, align 4
864// CHECK-NEXT: bitcast
865// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align 4 %{{.*}}, i8 0, i64 4, i1 false)
866// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
867
868TEST_CUSTOM(unmatchedreverse, unmatchedreverse, { .c = 42 });
869// CHECK-LABEL: @test_unmatchedreverse_custom()
870// CHECK: %custom = alloca %union.unmatchedreverse, align 4
871// CHECK-NEXT: bitcast
872// CHECK-NEXT: call void @llvm.memcpy
873// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
874
875TEST_UNINIT(unmatchedfp, unmatchedfp);
876// CHECK-LABEL: @test_unmatchedfp_uninit()
877// CHECK: %uninit = alloca %union.unmatchedfp, align 8
878// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
879
880TEST_BRACES(unmatchedfp, unmatchedfp);
881// CHECK-LABEL: @test_unmatchedfp_braces()
882// CHECK: %braces = alloca %union.unmatchedfp, align 8
883// CHECK-NEXT: bitcast
884// CHECK-NEXT: call void @llvm.memcpy
885// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
886
887TEST_CUSTOM(unmatchedfp, unmatchedfp, { .d = 3.1415926535897932384626433 });
888// CHECK-LABEL: @test_unmatchedfp_custom()
889// CHECK: %custom = alloca %union.unmatchedfp, align 8
890// CHECK-NEXT: bitcast
891// CHECK-NEXT: call void @llvm.memcpy
892// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
893
894
895TEST_UNINIT(emptyenum, emptyenum);
896// CHECK-LABEL: @test_emptyenum_uninit()
897// CHECK: %uninit = alloca i32, align 4
898// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
899
900TEST_BRACES(emptyenum, emptyenum);
901// CHECK-LABEL: @test_emptyenum_braces()
902// CHECK: %braces = alloca i32, align 4
903// CHECK-NEXT: store i32 0, i32* %braces, align 4
904// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
905
906TEST_CUSTOM(emptyenum, emptyenum, { (emptyenum)42 });
907// CHECK-LABEL: @test_emptyenum_custom()
908// CHECK: %custom = alloca i32, align 4
909// CHECK-NEXT: store i32 42, i32* %custom, align 4
910// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
911
912TEST_UNINIT(smallenum, smallenum);
913// CHECK-LABEL: @test_smallenum_uninit()
914// CHECK: %uninit = alloca i32, align 4
915// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
916
917TEST_BRACES(smallenum, smallenum);
918// CHECK-LABEL: @test_smallenum_braces()
919// CHECK: %braces = alloca i32, align 4
920// CHECK-NEXT: store i32 0, i32* %braces, align 4
921// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
922
923TEST_CUSTOM(smallenum, smallenum, { (smallenum)42 });
924// CHECK-LABEL: @test_smallenum_custom()
925// CHECK: %custom = alloca i32, align 4
926// CHECK-NEXT: store i32 42, i32* %custom, align 4
927// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
928
929
930TEST_UNINIT(intvec16, int __attribute__((vector_size(16))));
931// CHECK-LABEL: @test_intvec16_uninit()
932// CHECK: %uninit = alloca <4 x i32>, align 16
933// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
934
935TEST_BRACES(intvec16, int __attribute__((vector_size(16))));
936// CHECK-LABEL: @test_intvec16_braces()
937// CHECK: %braces = alloca <4 x i32>, align 16
938// CHECK-NEXT: store <4 x i32> zeroinitializer, <4 x i32>* %braces, align 16
939// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
940
941 TEST_CUSTOM(intvec16, int __attribute__((vector_size(16))), { 0x44444444, 0x44444444, 0x44444444, 0x44444444 });
942// CHECK-LABEL: @test_intvec16_custom()
943// CHECK: %custom = alloca <4 x i32>, align 16
944// CHECK-NEXT: store <4 x i32> <i32 1145324612, i32 1145324612, i32 1145324612, i32 1145324612>, <4 x i32>* %custom, align 16
945// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
946
947TEST_UNINIT(longlongvec32, long long __attribute__((vector_size(32))));
948// CHECK-LABEL: @test_longlongvec32_uninit()
JF Bastien81377932018-08-07 04:44:13 +0000949// CHECK: %uninit = alloca <4 x i64>, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000950// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
951
952TEST_BRACES(longlongvec32, long long __attribute__((vector_size(32))));
953// CHECK-LABEL: @test_longlongvec32_braces()
JF Bastien81377932018-08-07 04:44:13 +0000954// CHECK: %braces = alloca <4 x i64>, align [[ALIGN:[0-9]*]]
955// CHECK-NEXT: store <4 x i64> zeroinitializer, <4 x i64>* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000956// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
957
958TEST_CUSTOM(longlongvec32, long long __attribute__((vector_size(32))), { 0x3333333333333333, 0x3333333333333333, 0x3333333333333333, 0x3333333333333333 });
959// CHECK-LABEL: @test_longlongvec32_custom()
JF Bastien81377932018-08-07 04:44:13 +0000960// CHECK: %custom = alloca <4 x i64>, align [[ALIGN:[0-9]*]]
961// CHECK-NEXT: store <4 x i64> <i64 3689348814741910323, i64 3689348814741910323, i64 3689348814741910323, i64 3689348814741910323>, <4 x i64>* %custom, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000962// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
963
964TEST_UNINIT(floatvec16, float __attribute__((vector_size(16))));
965// CHECK-LABEL: @test_floatvec16_uninit()
JF Bastien81377932018-08-07 04:44:13 +0000966// CHECK: %uninit = alloca <4 x float>, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000967// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
968
969TEST_BRACES(floatvec16, float __attribute__((vector_size(16))));
970// CHECK-LABEL: @test_floatvec16_braces()
JF Bastien81377932018-08-07 04:44:13 +0000971// CHECK: %braces = alloca <4 x float>, align [[ALIGN:[0-9]*]]
972// CHECK-NEXT: store <4 x float> zeroinitializer, <4 x float>* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000973// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
974
975TEST_CUSTOM(floatvec16, float __attribute__((vector_size(16))), { 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433 });
976// CHECK-LABEL: @test_floatvec16_custom()
JF Bastien81377932018-08-07 04:44:13 +0000977// CHECK: %custom = alloca <4 x float>, align [[ALIGN:[0-9]*]]
978// CHECK-NEXT: store <4 x float> <float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000, float 0x400921FB60000000>, <4 x float>* %custom, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000979// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
980
981TEST_UNINIT(doublevec32, double __attribute__((vector_size(32))));
982// CHECK-LABEL: @test_doublevec32_uninit()
JF Bastien81377932018-08-07 04:44:13 +0000983// CHECK: %uninit = alloca <4 x double>, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000984// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
985
986TEST_BRACES(doublevec32, double __attribute__((vector_size(32))));
987// CHECK-LABEL: @test_doublevec32_braces()
JF Bastien81377932018-08-07 04:44:13 +0000988// CHECK: %braces = alloca <4 x double>, align [[ALIGN:[0-9]*]]
989// CHECK-NEXT: store <4 x double> zeroinitializer, <4 x double>* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000990// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
991
992TEST_CUSTOM(doublevec32, double __attribute__((vector_size(32))), { 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433 });
993// CHECK-LABEL: @test_doublevec32_custom()
JF Bastien81377932018-08-07 04:44:13 +0000994// CHECK: %custom = alloca <4 x double>, align [[ALIGN:[0-9]*]]
995// CHECK-NEXT: store <4 x double> <double 0x400921FB54442D18, double 0x400921FB54442D18, double 0x400921FB54442D18, double 0x400921FB54442D18>, <4 x double>* %custom, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000996// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
997
998
999} // extern "C"