blob: 1d6bfffe73ddbaa17958c5359cc8700890359876 [file] [log] [blame]
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK,CHECK-O0
2// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK-O0,PATTERN,PATTERN-O0
Leonard Chanf6630922019-06-21 16:03:06 +00003// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=pattern %s -O1 -fno-experimental-new-pass-manager -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK-O1,PATTERN,PATTERN-O1,PATTERN-O1-LEGACY
4// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=pattern %s -O1 -fexperimental-new-pass-manager -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK-O1,PATTERN,PATTERN-O1,PATTERN-O1-NEWPM
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00005// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK-O0,ZERO,ZERO-O0
Leonard Chanf6630922019-06-21 16:03:06 +00006// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero %s -O1 -fno-experimental-new-pass-manager -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-LEGACY
7// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks -ftrivial-auto-var-init=zero %s -O1 -fexperimental-new-pass-manager -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-NEWPM
Vitaly Buka669ad5f2019-07-12 01:36:11 +00008// RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown -fblocks -ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK-O0,PATTERN,PATTERN-O0
JF Bastienc70f65e2018-08-07 03:12:52 +00009
Vitaly Bukaf55aad02019-07-11 21:59:09 +000010#pragma clang diagnostic ignored "-Winaccessible-base"
11
Vitaly Buka669ad5f2019-07-12 01:36:11 +000012#ifdef __x86_64__
13char inits[] = {"-86/-21846/-1431655766/i64/-6148914691236517206/-6148914691236517206/i128/-113427455640312821154458202477256070486/i64/-6148914691236517206/AA/"};
14#else
15char inits[] = {"-86/-21846/-1431655766/i32/-1431655766/-6148914691236517206/i32/-1431655766/i32/170/AA/"};
16#define __int128 int;
17#endif
18// PATTERN: @inits = {{.*}} c"[[I8:[^/]+]]/[[I16:[^/]+]]/[[I32:[^/]+]]/[[ILONGT:[^/]+]]/[[ILONG:[^/]+]]/[[I64:[^/]+]]/[[I128T:[^/]+]]/[[I128:[^/]+]]/[[IPTRT:[^/]+]]/[[IPTR:[^/]+]]/[[IC:[^/]+]]/\00", align 1
19
JF Bastienc70f65e2018-08-07 03:12:52 +000020template<typename T> void used(T &) noexcept;
21
22#define TEST_UNINIT(NAME, TYPE) \
23 using type_##NAME = TYPE; \
24 void test_##NAME##_uninit() { \
25 type_##NAME uninit; \
26 used(uninit); \
27 }
28
29// Value initialization on scalars, aggregate initialization on aggregates.
30#define TEST_BRACES(NAME, TYPE) \
31 using type_##NAME = TYPE; \
32 void test_##NAME##_braces() { \
33 type_##NAME braces = {}; \
34 used(braces); \
35 }
36
37#define TEST_CUSTOM(NAME, TYPE, ...) \
38 using type_##NAME = TYPE; \
39 void test_##NAME##_custom() { \
40 type_##NAME custom __VA_ARGS__; \
41 used(custom); \
42 }
43
JF Bastien14daa202018-12-18 05:12:21 +000044// None of the synthesized globals should contain `undef`.
45// PATTERN-NOT: undef
46// ZERO-NOT: undef
47
Vitaly Buka669ad5f2019-07-12 01:36:11 +000048// PATTERN-O0: @__const.test_empty_uninit.uninit = private unnamed_addr constant %struct.empty { i8 [[I8]] }, align 1
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +000049// PATTERN-O1-NOT: @__const.test_empty_uninit.uninit
JF Bastienc70f65e2018-08-07 03:12:52 +000050struct empty {};
Vitaly Buka669ad5f2019-07-12 01:36:11 +000051// PATTERN-O0: @__const.test_small_uninit.uninit = private unnamed_addr constant %struct.small { i8 [[I8]] }, align 1
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +000052// PATTERN-O0: @__const.test_small_custom.custom = private unnamed_addr constant %struct.small { i8 42 }, align 1
53// ZERO-O0: @__const.test_small_custom.custom = private unnamed_addr constant %struct.small { i8 42 }, align 1
54// PATTERN-O1-NOT: @__const.test_small_uninit.uninit
55// PATTERN-O1-NOT: @__const.test_small_custom.custom
56// ZERO-O1-NOT: @__const.test_small_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +000057struct small { char c; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +000058// PATTERN-O0: @__const.test_smallinit_uninit.uninit = private unnamed_addr constant %struct.smallinit { i8 [[I8]] }, align 1
59// PATTERN-O0: @__const.test_smallinit_braces.braces = private unnamed_addr constant %struct.smallinit { i8 [[I8]] }, align 1
60// PATTERN-O0: @__const.test_smallinit_custom.custom = private unnamed_addr constant %struct.smallinit { i8 [[I8]] }, align 1
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +000061// PATTERN-O1-NOT: @__const.test_smallinit_uninit.uninit
62// PATTERN-O1-NOT: @__const.test_smallinit_braces.braces
63// PATTERN-O1-NOT: @__const.test_smallinit_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +000064struct smallinit { char c = 42; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +000065// PATTERN-O0: @__const.test_smallpartinit_uninit.uninit = private unnamed_addr constant %struct.smallpartinit { i8 [[I8]], i8 [[I8]] }, align 1
66// PATTERN-O0: @__const.test_smallpartinit_braces.braces = private unnamed_addr constant %struct.smallpartinit { i8 [[I8]], i8 [[I8]] }, align 1
67// PATTERN-O0: @__const.test_smallpartinit_custom.custom = private unnamed_addr constant %struct.smallpartinit { i8 [[I8]], i8 [[I8]] }, align 1
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +000068// PATTERN-O1-NOT: @__const.test_smallpartinit_uninit.uninit
69// PATTERN-O1-NOT: @__const.test_smallpartinit_braces.braces
70// PATTERN-O1-NOT: @__const.test_smallpartinit_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +000071struct smallpartinit { char c = 42, d; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +000072// PATTERN-O0: @__const.test_nullinit_uninit.uninit = private unnamed_addr constant %struct.nullinit { i8* inttoptr ([[IPTRT]] [[IPTR]] to i8*) }, align
73// PATTERN-O0: @__const.test_nullinit_braces.braces = private unnamed_addr constant %struct.nullinit { i8* inttoptr ([[IPTRT]] [[IPTR]] to i8*) }, align
74// PATTERN-O0: @__const.test_nullinit_custom.custom = private unnamed_addr constant %struct.nullinit { i8* inttoptr ([[IPTRT]] [[IPTR]] to i8*) }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +000075// PATTERN-O1-NOT: @__const.test_nullinit_uninit.uninit
76// PATTERN-O1-NOT: @__const.test_nullinit_braces.braces
77// PATTERN-O1-NOT: @__const.test_nullinit_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +000078struct nullinit { char* null = nullptr; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +000079// PATTERN-O0: @__const.test_padded_uninit.uninit = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] }, align 4
JF Bastiencdf26f12019-04-30 23:27:28 +000080// PATTERN-O0: @__const.test_padded_custom.custom = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +000081// ZERO-O0: @__const.test_padded_custom.custom = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 }, align 4
82// PATTERN-O1-NOT: @__const.test_padded_uninit.uninit
83// PATTERN-O1-NOT: @__const.test_padded_custom.custom
84// ZERO-O1-NOT: @__const.test_padded_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +000085struct padded { char c; int i; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +000086// PATTERN-O0: @__const.test_paddednullinit_uninit.uninit = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] }, align 4
87// PATTERN-O0: @__const.test_paddednullinit_braces.braces = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] }, align 4
88// PATTERN-O0: @__const.test_paddednullinit_custom.custom = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +000089// PATTERN-O1-NOT: @__const.test_paddednullinit_uninit.uninit
90// PATTERN-O1-NOT: @__const.test_paddednullinit_braces.braces
91// PATTERN-O1-NOT: @__const.test_paddednullinit_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +000092struct paddednullinit { char c = 0; int i = 0; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +000093// PATTERN-O0: @__const.test_paddedpacked_uninit.uninit = private unnamed_addr constant %struct.paddedpacked <{ i8 [[I8]], i32 [[I32]] }>, align 1
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +000094// PATTERN: @__const.test_paddedpacked_custom.custom = private unnamed_addr constant %struct.paddedpacked <{ i8 42, i32 13371337 }>, align 1
95// ZERO: @__const.test_paddedpacked_custom.custom = private unnamed_addr constant %struct.paddedpacked <{ i8 42, i32 13371337 }>, align 1
96struct paddedpacked { char c; int i; } __attribute__((packed));
Vitaly Buka669ad5f2019-07-12 01:36:11 +000097// PATTERN-O0: @__const.test_paddedpackedarray_uninit.uninit = private unnamed_addr constant %struct.paddedpackedarray { [2 x %struct.paddedpacked] [%struct.paddedpacked <{ i8 [[I8]], i32 [[I32]] }>, %struct.paddedpacked <{ i8 [[I8]], i32 [[I32]] }>] }, align 1
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +000098// PATTERN: @__const.test_paddedpackedarray_custom.custom = private unnamed_addr constant %struct.paddedpackedarray { [2 x %struct.paddedpacked] [%struct.paddedpacked <{ i8 42, i32 13371337 }>, %struct.paddedpacked <{ i8 43, i32 13371338 }>] }, align 1
99// ZERO: @__const.test_paddedpackedarray_custom.custom = private unnamed_addr constant %struct.paddedpackedarray { [2 x %struct.paddedpacked] [%struct.paddedpacked <{ i8 42, i32 13371337 }>, %struct.paddedpacked <{ i8 43, i32 13371338 }>] }, align 1
100struct paddedpackedarray { struct paddedpacked p[2]; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000101// PATTERN-O0: @__const.test_unpackedinpacked_uninit.uninit = private unnamed_addr constant <{ { i8, [3 x i8], i32 }, i8 }> <{ { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] }, i8 [[I8]] }>, align 1
Peter Collingbourne68b46732019-03-16 19:25:39 +0000102struct unpackedinpacked { padded a; char b; } __attribute__((packed));
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000103// PATTERN-O0: @__const.test_paddednested_uninit.uninit = private unnamed_addr constant { { i8, [3 x i8], i32 }, { i8, [3 x i8], i32 } } { { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] }, { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] } }, align 4
JF Bastiencdf26f12019-04-30 23:27:28 +0000104// PATTERN: @__const.test_paddednested_custom.custom = private unnamed_addr constant { { i8, [3 x i8], i32 }, { i8, [3 x i8], i32 } } { { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 }, { i8, [3 x i8], i32 } { i8 43, [3 x i8] zeroinitializer, i32 13371338 } }, align 4
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000105// ZERO: @__const.test_paddednested_custom.custom = private unnamed_addr constant { { i8, [3 x i8], i32 }, { i8, [3 x i8], i32 } } { { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 }, { i8, [3 x i8], i32 } { i8 43, [3 x i8] zeroinitializer, i32 13371338 } }, align 4
106struct paddednested { struct padded p1, p2; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000107// PATTERN-O0: @__const.test_paddedpackednested_uninit.uninit = private unnamed_addr constant %struct.paddedpackednested { %struct.paddedpacked <{ i8 [[I8]], i32 [[I32]] }>, %struct.paddedpacked <{ i8 [[I8]], i32 [[I32]] }> }, align 1
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000108// PATTERN: @__const.test_paddedpackednested_custom.custom = private unnamed_addr constant %struct.paddedpackednested { %struct.paddedpacked <{ i8 42, i32 13371337 }>, %struct.paddedpacked <{ i8 43, i32 13371338 }> }, align 1
109// ZERO: @__const.test_paddedpackednested_custom.custom = private unnamed_addr constant %struct.paddedpackednested { %struct.paddedpacked <{ i8 42, i32 13371337 }>, %struct.paddedpacked <{ i8 43, i32 13371338 }> }, align 1
110struct paddedpackednested { struct paddedpacked p1, p2; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000111// PATTERN-O0: @__const.test_bitfield_uninit.uninit = private unnamed_addr constant %struct.bitfield { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]" }, align 4
112// PATTERN-O0: @__const.test_bitfield_custom.custom = private unnamed_addr constant %struct.bitfield { i8 20, [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]" }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000113// ZERO-O0: @__const.test_bitfield_custom.custom = private unnamed_addr constant %struct.bitfield { i8 20, [3 x i8] zeroinitializer }, align 4
114// PATTERN-O1-NOT: @__const.test_bitfield_uninit.uninit
115// PATTERN-O1-NOT: @__const.test_bitfield_custom.custom
116// ZERO-O1-NOT: @__const.test_bitfield_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000117struct bitfield { int i : 4; int j : 2; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000118// PATTERN-O0: @__const.test_bitfieldaligned_uninit.uninit = private unnamed_addr constant %struct.bitfieldaligned { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]" }, align 4
119// PATTERN-O0: @__const.test_bitfieldaligned_custom.custom = private unnamed_addr constant %struct.bitfieldaligned { i8 4, [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i8 1, [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]" }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000120// ZERO-O0: @__const.test_bitfieldaligned_custom.custom = private unnamed_addr constant %struct.bitfieldaligned { i8 4, [3 x i8] zeroinitializer, i8 1, [3 x i8] zeroinitializer }, align 4
121// PATTERN-O1-NOT: @__const.test_bitfieldaligned_uninit.uninit
122// PATTERN-O1-NOT: @__const.test_bitfieldaligned_custom.custom
123// ZERO-O1-NOT: @__const.test_bitfieldaligned_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000124struct bitfieldaligned { int i : 4; int : 0; int j : 2; };
125struct 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; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000126// PATTERN-O0: @__const.test_arraytail_uninit.uninit = private unnamed_addr constant %struct.arraytail { i32 [[I32]], [0 x i32] zeroinitializer }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000127// PATTERN-O0: @__const.test_arraytail_custom.custom = private unnamed_addr constant %struct.arraytail { i32 57005, [0 x i32] zeroinitializer }, align 4
128// ZERO-O0: @__const.test_arraytail_custom.custom = private unnamed_addr constant %struct.arraytail { i32 57005, [0 x i32] zeroinitializer }, align 4
129// PATTERN-O1-NOT: @__const.test_arraytail_uninit.uninit
130// PATTERN-O1-NOT: @__const.test_arraytail_custom.custom
131// ZERO-O1-NOT: @__const.test_arraytail_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000132struct arraytail { int i; int arr[]; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000133// PATTERN-O0: @__const.test_int1_uninit.uninit = private unnamed_addr constant [1 x i32] {{\[}}i32 [[I32]]], align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000134// PATTERN-O0: @__const.test_int1_custom.custom = private unnamed_addr constant [1 x i32] [i32 858993459], align 4
135// ZERO-O0: @__const.test_int1_custom.custom = private unnamed_addr constant [1 x i32] [i32 858993459], align 4
136// PATTERN-O1-NOT: @__const.test_int1_uninit.uninit
137// PATTERN-O1-NOT: @__const.test_int1_custom.custom
138// ZERO-O1-NOT: @__const.test_int1_custom.custom
139
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000140// PATTERN-O0: @__const.test_bool4_uninit.uninit = private unnamed_addr constant [4 x i8] c"\[[IC]]\[[IC]]\[[IC]]\[[IC]]", align 1
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000141// PATTERN-O0: @__const.test_bool4_custom.custom = private unnamed_addr constant [4 x i8] c"\01\01\01\01", align 1
142// ZERO-O0: @__const.test_bool4_custom.custom = private unnamed_addr constant [4 x i8] c"\01\01\01\01", align 1
143// PATTERN-O1-NOT: @__const.test_bool4_uninit.uninit
144// PATTERN-O1-NOT: @__const.test_bool4_custom.custom
145// ZERO-O1-NOT: @__const.test_bool4_custom.custom
146
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000147// PATTERN: @__const.test_intptr4_custom.custom = private unnamed_addr constant [4 x i32*] [i32* inttoptr ([[IPTRT]] 572662306 to i32*), i32* inttoptr ([[IPTRT]] 572662306 to i32*), i32* inttoptr ([[IPTRT]] 572662306 to i32*), i32* inttoptr ([[IPTRT]] 572662306 to i32*)], align
JF Bastien14daa202018-12-18 05:12:21 +0000148// ZERO: @__const.test_intptr4_custom.custom = private unnamed_addr constant [4 x i32*] [i32* inttoptr (i64 572662306 to i32*), i32* inttoptr (i64 572662306 to i32*), i32* inttoptr (i64 572662306 to i32*), i32* inttoptr (i64 572662306 to i32*)], align 16
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000149// PATTERN-O0: @__const.test_tailpad4_uninit.uninit = private unnamed_addr constant [4 x { i16, i8, [1 x i8] }] [{ i16, i8, [1 x i8] } { i16 [[I16]], i8 [[I8]], [1 x i8] c"\[[IC]]" }, { i16, i8, [1 x i8] } { i16 [[I16]], i8 [[I8]], [1 x i8] c"\[[IC]]" }, { i16, i8, [1 x i8] } { i16 [[I16]], i8 [[I8]], [1 x i8] c"\[[IC]]" }, { i16, i8, [1 x i8] } { i16 [[I16]], i8 [[I8]], [1 x i8] c"\[[IC]]" }], align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000150// PATTERN-O1-NOT: @__const.test_tailpad4_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000151// PATTERN: @__const.test_tailpad4_custom.custom = private unnamed_addr constant [4 x { i16, i8, [1 x i8] }] [{ i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }], align
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000152// ZERO: @__const.test_tailpad4_custom.custom = private unnamed_addr constant [4 x { i16, i8, [1 x i8] }] [{ i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] zeroinitializer }], align 16
JF Bastienc70f65e2018-08-07 03:12:52 +0000153struct tailpad { short s; char c; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000154// PATTERN-O0: @__const.test_atomicnotlockfree_uninit.uninit = private unnamed_addr constant %struct.notlockfree { [4 x i64] {{\[}}i64 [[I64]], i64 [[I64]], i64 [[I64]], i64 [[I64]]] }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000155// PATTERN-O1-NOT: @__const.test_atomicnotlockfree_uninit.uninit
JF Bastienc70f65e2018-08-07 03:12:52 +0000156struct notlockfree { long long a[4]; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000157// PATTERN-O0: @__const.test_atomicpadded_uninit.uninit = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 [[I8]], [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]", i32 [[I32]] }, align 8
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000158// PATTERN-O1-NOT: @__const.test_atomicpadded_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000159// PATTERN-O0: @__const.test_atomictailpad_uninit.uninit = private unnamed_addr constant { i16, i8, [1 x i8] } { i16 [[I16]], i8 [[I8]], [1 x i8] c"\[[IC]]" }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000160// PATTERN-O1-NOT: @__const.test_atomictailpad_uninit.uninit
161// PATTERN-O0: @__const.test_complexfloat_uninit.uninit = private unnamed_addr constant { float, float } { float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000 }, align 4
162// PATTERN-O1-NOT: @__const.test_complexfloat_uninit.uninit
163// PATTERN-O0: @__const.test_complexfloat_braces.braces = private unnamed_addr constant { float, float } { float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000 }, align 4
164// PATTERN-O1-NOT: @__const.test_complexfloat_braces.braces
165// PATTERN-O0: @__const.test_complexfloat_custom.custom = private unnamed_addr constant { float, float } { float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000 }, align 4
166// PATTERN-O1-NOT: @__const.test_complexfloat_custom.custom
167// PATTERN-O0: @__const.test_complexdouble_uninit.uninit = private unnamed_addr constant { double, double } { double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF }, align 8
168// PATTERN-O1-NOT: @__const.test_complexdouble_uninit.uninit
169// PATTERN-O0: @__const.test_complexdouble_braces.braces = private unnamed_addr constant { double, double } { double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF }, align 8
170// PATTERN-O1-NOT: @__const.test_complexdouble_braces.braces
171// PATTERN-O0: @__const.test_complexdouble_custom.custom = private unnamed_addr constant { double, double } { double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF }, align 8
172// PATTERN-O1-NOT: @__const.test_complexdouble_custom.custom
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000173// PATTERN-O0: @__const.test_semivolatile_uninit.uninit = private unnamed_addr constant %struct.semivolatile { i32 [[I32]], i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000174// PATTERN-O0: @__const.test_semivolatile_custom.custom = private unnamed_addr constant %struct.semivolatile { i32 1145324612, i32 1145324612 }, align 4
175// PATTERN-O1-NOT: @__const.test_semivolatile_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000176struct semivolatile { int i; volatile int vi; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000177// PATTERN-O0: @__const.test_semivolatileinit_uninit.uninit = private unnamed_addr constant %struct.semivolatileinit { i32 [[I32]], i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000178// PATTERN-O1-NOT: @__const.test_semivolatileinit_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000179// PATTERN-O0: @__const.test_semivolatileinit_braces.braces = private unnamed_addr constant %struct.semivolatileinit { i32 [[I32]], i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000180// PATTERN-O1-NOT: @__const.test_semivolatileinit_braces.braces
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000181// PATTERN-O0: @__const.test_semivolatileinit_custom.custom = private unnamed_addr constant %struct.semivolatileinit { i32 [[I32]], i32 [[I32]] }, align 4
182// PATTERN-O1-NOT: @__const.test_semivolatileinit_custom.custom = private unnamed_addr constant %struct.semivolatileinit { i32 [[I32]], i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000183// ZERO-O0: @__const.test_semivolatile_custom.custom = private unnamed_addr constant %struct.semivolatile { i32 1145324612, i32 1145324612 }, align 4
184// ZERO-O1-NOT: @__const.test_semivolatile_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000185struct semivolatileinit { int i = 0x11111111; volatile int vi = 0x11111111; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000186// PATTERN-O0: @__const.test_base_uninit.uninit = private unnamed_addr constant %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000187// PATTERN-O1-NOT: @__const.test_base_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000188// PATTERN-O0: @__const.test_base_braces.braces = private unnamed_addr constant %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000189// PATTERN-O1-NOT: @__const.test_base_braces.braces
JF Bastienc70f65e2018-08-07 03:12:52 +0000190struct base { virtual ~base(); };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000191// PATTERN-O0: @__const.test_derived_uninit.uninit = private unnamed_addr constant %struct.derived { %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) } }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000192// PATTERN-O1-NOT: @__const.test_derived_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000193// PATTERN-O0: @__const.test_derived_braces.braces = private unnamed_addr constant %struct.derived { %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) } }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000194// PATTERN-O1-NOT: @__const.test_derived_braces.braces
JF Bastienc70f65e2018-08-07 03:12:52 +0000195struct derived : public base {};
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000196// PATTERN-O0: @__const.test_virtualderived_uninit.uninit = private unnamed_addr constant %struct.virtualderived { %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) }, %struct.derived { %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) } } }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000197// PATTERN-O1-NOT: @__const.test_virtualderived_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000198// PATTERN-O0: @__const.test_virtualderived_braces.braces = private unnamed_addr constant %struct.virtualderived { %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) }, %struct.derived { %struct.base { i32 (...)** inttoptr ([[IPTRT]] [[IPTR]] to i32 (...)**) } } }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000199// PATTERN-O1-NOT: @__const.test_virtualderived_braces.braces
JF Bastienc70f65e2018-08-07 03:12:52 +0000200struct virtualderived : public virtual base, public virtual derived {};
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000201// PATTERN-O0: @__const.test_matching_uninit.uninit = private unnamed_addr constant %union.matching { i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000202// PATTERN-O1-NOT: @__const.test_matching_uninit.uninit
203// PATTERN-O0: @__const.test_matching_custom.custom = private unnamed_addr constant { float } { float 6.145500e+04 }, align 4
204// PATTERN-O1-NOT: @__const.test_matching_custom.custom
205// ZERO-O0: @__const.test_matching_custom.custom = private unnamed_addr constant { float } { float 6.145500e+04 }, align 4
206// ZERO-O1-NOT: @__const.test_matching_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000207union matching { int i; float f; };
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000208// PATTERN-O0: @__const.test_matchingreverse_uninit.uninit = private unnamed_addr constant %union.matchingreverse { float 0xFFFFFFFFE0000000 }, align 4
209// PATTERN-O1-NOT: @__const.test_matchingreverse_uninit.uninit
210// PATTERN-O0: @__const.test_matchingreverse_custom.custom = private unnamed_addr constant { i32 } { i32 61455 }, align 4
211// PATTERN-O1-NOT: @__const.test_matchingreverse_custom.custom
212// ZERO-O0: @__const.test_matchingreverse_custom.custom = private unnamed_addr constant { i32 } { i32 61455 }, align 4
213// ZERO-O1-NOT: @__const.test_matchingreverse_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000214union matchingreverse { float f; int i; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000215// PATTERN-O0: @__const.test_unmatched_uninit.uninit = private unnamed_addr constant %union.unmatched { i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000216// PATTERN-O1-NOT: @__const.test_unmatched_uninit.uninit
217// PATTERN-O0: @__const.test_unmatched_custom.custom = private unnamed_addr constant %union.unmatched { i32 1001242351 }, align 4
218// PATTERN-O1-NOT: @__const.test_unmatched_custom.custom
219// ZERO-O0: @__const.test_unmatched_custom.custom = private unnamed_addr constant %union.unmatched { i32 1001242351 }, align 4
220// ZERO-O1-NOT: @__const.test_unmatched_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000221union unmatched { char c; int i; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000222// PATTERN-O0: @__const.test_unmatchedreverse_uninit.uninit = private unnamed_addr constant %union.unmatchedreverse { i32 [[I32]] }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000223// PATTERN-O1-NOT: @__const.test_unmatchedreverse_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000224// PATTERN-O0: @__const.test_unmatchedreverse_custom.custom = private unnamed_addr constant { i8, [3 x i8] } { i8 42, [3 x i8] c"\[[IC]]\[[IC]]\[[IC]]" }, align 4
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000225// PATTERN-O1-NOT: @__const.test_unmatchedreverse_custom.custom
226// ZERO-O0: @__const.test_unmatchedreverse_custom.custom = private unnamed_addr constant { i8, [3 x i8] } { i8 42, [3 x i8] zeroinitializer }, align 4
227// ZERO-O1-NOT: @__const.test_unmatchedreverse_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000228union unmatchedreverse { int i; char c; };
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000229// PATTERN-O0: @__const.test_unmatchedfp_uninit.uninit = private unnamed_addr constant %union.unmatchedfp { double 0xFFFFFFFFFFFFFFFF }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000230// PATTERN-O1-NOT: @__const.test_unmatchedfp_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000231// PATTERN-O0: @__const.test_unmatchedfp_custom.custom = private unnamed_addr constant %union.unmatchedfp { double 0x400921FB54442D18 }, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000232// PATTERN-O1-NOT: @__const.test_unmatchedfp_custom.custom
233// ZERO-O0: @__const.test_unmatchedfp_custom.custom = private unnamed_addr constant %union.unmatchedfp { double 0x400921FB54442D18 }, align 8
234// ZERO-O1-NOT: @__const.test_unmatchedfp_custom.custom
JF Bastienc70f65e2018-08-07 03:12:52 +0000235union unmatchedfp { float f; double d; };
236enum emptyenum {};
237enum smallenum { VALUE };
238
239extern "C" {
240
241TEST_UNINIT(char, char);
242// CHECK-LABEL: @test_char_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000243// CHECK: %uninit = alloca i8, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000244// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000245// PATTERN-LABEL: @test_char_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000246// PATTERN: store i8 [[I8]], i8* %uninit, align 1
JF Bastien14daa202018-12-18 05:12:21 +0000247// ZERO-LABEL: @test_char_uninit()
248// ZERO: store i8 0, i8* %uninit, align 1
JF Bastienc70f65e2018-08-07 03:12:52 +0000249
250TEST_BRACES(char, char);
251// CHECK-LABEL: @test_char_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000252// CHECK: %braces = alloca i8, align [[ALIGN:[0-9]*]]
253// CHECK-NEXT: store i8 0, i8* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000254// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
255
256TEST_UNINIT(uchar, unsigned char);
257// CHECK-LABEL: @test_uchar_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000258// CHECK: %uninit = alloca i8, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000259// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000260// PATTERN-LABEL: @test_uchar_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000261// PATTERN: store i8 [[I8]], i8* %uninit, align 1
JF Bastien14daa202018-12-18 05:12:21 +0000262// ZERO-LABEL: @test_uchar_uninit()
263// ZERO: store i8 0, i8* %uninit, align 1
JF Bastienc70f65e2018-08-07 03:12:52 +0000264
265TEST_BRACES(uchar, unsigned char);
266// CHECK-LABEL: @test_uchar_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000267// CHECK: %braces = alloca i8, align [[ALIGN:[0-9]*]]
268// CHECK-NEXT: store i8 0, i8* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000269// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
270
271TEST_UNINIT(schar, signed char);
272// CHECK-LABEL: @test_schar_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000273// CHECK: %uninit = alloca i8, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000274// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000275// PATTERN-LABEL: @test_schar_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000276// PATTERN: store i8 [[I8]], i8* %uninit, align 1
JF Bastien14daa202018-12-18 05:12:21 +0000277// ZERO-LABEL: @test_schar_uninit()
278// ZERO: store i8 0, i8* %uninit, align 1
JF Bastienc70f65e2018-08-07 03:12:52 +0000279
280TEST_BRACES(schar, signed char);
281// CHECK-LABEL: @test_schar_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000282// CHECK: %braces = alloca i8, align [[ALIGN:[0-9]*]]
283// CHECK-NEXT: store i8 0, i8* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000284// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
285
286TEST_UNINIT(wchar_t, wchar_t);
287// CHECK-LABEL: @test_wchar_t_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000288// CHECK: %uninit = alloca i32, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000289// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000290// PATTERN-LABEL: @test_wchar_t_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000291// PATTERN: store i32 [[I32]], i32* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000292// ZERO-LABEL: @test_wchar_t_uninit()
293// ZERO: store i32 0, i32* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000294
295TEST_BRACES(wchar_t, wchar_t);
296// CHECK-LABEL: @test_wchar_t_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000297// CHECK: %braces = alloca i32, align [[ALIGN:[0-9]*]]
298// CHECK-NEXT: store i32 0, i32* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000299// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
300
301TEST_UNINIT(short, short);
302// CHECK-LABEL: @test_short_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000303// CHECK: %uninit = alloca i16, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000304// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000305// PATTERN-LABEL: @test_short_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000306// PATTERN: store i16 [[I16]], i16* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000307// ZERO-LABEL: @test_short_uninit()
308// ZERO: store i16 0, i16* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000309
310TEST_BRACES(short, short);
311// CHECK-LABEL: @test_short_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000312// CHECK: %braces = alloca i16, align [[ALIGN:[0-9]*]]
313// CHECK-NEXT: store i16 0, i16* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000314// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
315
316TEST_UNINIT(ushort, unsigned short);
317// CHECK-LABEL: @test_ushort_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000318// CHECK: %uninit = alloca i16, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000319// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000320// PATTERN-LABEL: @test_ushort_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000321// PATTERN: store i16 [[I16]], i16* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000322// ZERO-LABEL: @test_ushort_uninit()
323// ZERO: store i16 0, i16* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000324
325TEST_BRACES(ushort, unsigned short);
326// CHECK-LABEL: @test_ushort_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000327// CHECK: %braces = alloca i16, align [[ALIGN:[0-9]*]]
328// CHECK-NEXT: store i16 0, i16* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000329// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
330
331TEST_UNINIT(int, int);
332// CHECK-LABEL: @test_int_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000333// CHECK: %uninit = alloca i32, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000334// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000335// PATTERN-LABEL: @test_int_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000336// PATTERN: store i32 [[I32]], i32* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000337// ZERO-LABEL: @test_int_uninit()
338// ZERO: store i32 0, i32* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000339
340TEST_BRACES(int, int);
341// CHECK-LABEL: @test_int_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000342// CHECK: %braces = alloca i32, align [[ALIGN:[0-9]*]]
343// CHECK-NEXT: store i32 0, i32* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000344// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
345
346TEST_UNINIT(unsigned, unsigned);
347// CHECK-LABEL: @test_unsigned_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000348// CHECK: %uninit = alloca i32, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000349// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000350// PATTERN-LABEL: @test_unsigned_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000351// PATTERN: store i32 [[I32]], i32* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000352// ZERO-LABEL: @test_unsigned_uninit()
353// ZERO: store i32 0, i32* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000354
355TEST_BRACES(unsigned, unsigned);
356// CHECK-LABEL: @test_unsigned_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000357// CHECK: %braces = alloca i32, align [[ALIGN:[0-9]*]]
358// CHECK-NEXT: store i32 0, i32* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000359// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
360
361TEST_UNINIT(long, long);
362// CHECK-LABEL: @test_long_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000363// CHECK: %uninit = alloca i64, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000364// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000365// PATTERN-LABEL: @test_long_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000366// PATTERN: store [[ILONGT]] [[ILONG]], [[ILONGT]]* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000367// ZERO-LABEL: @test_long_uninit()
368// ZERO: store i64 0, i64* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000369
370TEST_BRACES(long, long);
371// CHECK-LABEL: @test_long_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000372// CHECK: %braces = alloca i64, align [[ALIGN:[0-9]*]]
373// CHECK-NEXT: store i64 0, i64* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000374// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
375
376TEST_UNINIT(ulong, unsigned long);
377// CHECK-LABEL: @test_ulong_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000378// CHECK: %uninit = alloca i64, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000379// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000380// PATTERN-LABEL: @test_ulong_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000381// PATTERN: store [[ILONGT]] [[ILONG]], [[ILONGT]]* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000382// ZERO-LABEL: @test_ulong_uninit()
383// ZERO: store i64 0, i64* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000384
385TEST_BRACES(ulong, unsigned long);
386// CHECK-LABEL: @test_ulong_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000387// CHECK: %braces = alloca i64, align [[ALIGN:[0-9]*]]
388// CHECK-NEXT: store i64 0, i64* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000389// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
390
391TEST_UNINIT(longlong, long long);
392// CHECK-LABEL: @test_longlong_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000393// CHECK: %uninit = alloca i64, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000394// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000395// PATTERN-LABEL: @test_longlong_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000396// PATTERN: store i64 [[I64]], i64* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000397// ZERO-LABEL: @test_longlong_uninit()
398// ZERO: store i64 0, i64* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000399
400TEST_BRACES(longlong, long long);
401// CHECK-LABEL: @test_longlong_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000402// CHECK: %braces = alloca i64, align [[ALIGN:[0-9]*]]
403// CHECK-NEXT: store i64 0, i64* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000404// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
405
406TEST_UNINIT(ulonglong, unsigned long long);
407// CHECK-LABEL: @test_ulonglong_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000408// CHECK: %uninit = alloca i64, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000409// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000410// PATTERN-LABEL: @test_ulonglong_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000411// PATTERN: store i64 [[I64]], i64* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000412// ZERO-LABEL: @test_ulonglong_uninit()
413// ZERO: store i64 0, i64* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000414
415TEST_BRACES(ulonglong, unsigned long long);
416// CHECK-LABEL: @test_ulonglong_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000417// CHECK: %braces = alloca i64, align [[ALIGN:[0-9]*]]
418// CHECK-NEXT: store i64 0, i64* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000419// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
420
421TEST_UNINIT(int128, __int128);
422// CHECK-LABEL: @test_int128_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000423// CHECK: %uninit = alloca i128, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000424// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000425// PATTERN-LABEL: @test_int128_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000426// PATTERN: store [[I128T]] [[I128]], [[I128T]]* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000427// ZERO-LABEL: @test_int128_uninit()
428// ZERO: store i128 0, i128* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000429
430TEST_BRACES(int128, __int128);
431// CHECK-LABEL: @test_int128_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000432// CHECK: %braces = alloca i128, align [[ALIGN:[0-9]*]]
433// CHECK-NEXT: store i128 0, i128* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000434// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
435
436TEST_UNINIT(uint128, unsigned __int128);
437// CHECK-LABEL: @test_uint128_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000438// CHECK: %uninit = alloca i128, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000439// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000440// PATTERN-LABEL: @test_uint128_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000441// PATTERN: store [[I128T]] [[I128]], [[I128T]]* %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000442// ZERO-LABEL: @test_uint128_uninit()
443// ZERO: store i128 0, i128* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000444
445TEST_BRACES(uint128, unsigned __int128);
446// CHECK-LABEL: @test_uint128_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000447// CHECK: %braces = alloca i128, align [[ALIGN:[0-9]*]]
448// CHECK-NEXT: store i128 0, i128* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000449// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
JF Bastienc70f65e2018-08-07 03:12:52 +0000450
451TEST_UNINIT(fp16, __fp16);
452// CHECK-LABEL: @test_fp16_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000453// CHECK: %uninit = alloca half, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000454// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000455// PATTERN-LABEL: @test_fp16_uninit()
456// PATTERN: store half 0xHFFFF, half* %uninit, align
457// ZERO-LABEL: @test_fp16_uninit()
458// ZERO: store half 0xH0000, half* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000459
460TEST_BRACES(fp16, __fp16);
461// CHECK-LABEL: @test_fp16_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000462// CHECK: %braces = alloca half, align [[ALIGN:[0-9]*]]
463// CHECK-NEXT: store half 0xH0000, half* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000464// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
465
466TEST_UNINIT(float, float);
467// CHECK-LABEL: @test_float_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000468// CHECK: %uninit = alloca float, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000469// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000470// PATTERN-LABEL: @test_float_uninit()
471// PATTERN: store float 0xFFFFFFFFE0000000, float* %uninit, align
472// ZERO-LABEL: @test_float_uninit()
473// ZERO: store float 0.000000e+00, float* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000474
475TEST_BRACES(float, float);
476// CHECK-LABEL: @test_float_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000477// CHECK: %braces = alloca float, align [[ALIGN:[0-9]*]]
478// CHECK-NEXT: store float 0.000000e+00, float* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000479// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
480
481TEST_UNINIT(double, double);
482// CHECK-LABEL: @test_double_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000483// CHECK: %uninit = alloca double, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000484// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000485// PATTERN-LABEL: @test_double_uninit()
486// PATTERN: store double 0xFFFFFFFFFFFFFFFF, double* %uninit, align
487// ZERO-LABEL: @test_double_uninit()
488// ZERO: store double 0.000000e+00, double* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000489
490TEST_BRACES(double, double);
491// CHECK-LABEL: @test_double_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000492// CHECK: %braces = alloca double, align [[ALIGN:[0-9]*]]
493// CHECK-NEXT: store double 0.000000e+00, double* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000494// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
495
496TEST_UNINIT(longdouble, long double);
497// CHECK-LABEL: @test_longdouble_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000498// CHECK: %uninit = alloca x86_fp80, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000499// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000500// PATTERN-LABEL: @test_longdouble_uninit()
501// PATTERN: store x86_fp80 0xKFFFFFFFFFFFFFFFFFFFF, x86_fp80* %uninit, align
502// ZERO-LABEL: @test_longdouble_uninit()
503// ZERO: store x86_fp80 0xK00000000000000000000, x86_fp80* %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000504
505TEST_BRACES(longdouble, long double);
506// CHECK-LABEL: @test_longdouble_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000507// CHECK: %braces = alloca x86_fp80, align [[ALIGN:[0-9]*]]
508// CHECK-NEXT: store x86_fp80 0xK00000000000000000000, x86_fp80* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000509// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
510
511
512TEST_UNINIT(intptr, int*);
513// CHECK-LABEL: @test_intptr_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000514// CHECK: %uninit = alloca i32*, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000515// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000516// PATTERN-LABEL: @test_intptr_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000517// PATTERN: store i32* inttoptr ([[IPTRT]] [[IPTR]] to i32*), i32** %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000518// ZERO-LABEL: @test_intptr_uninit()
519// ZERO: store i32* null, i32** %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000520
521TEST_BRACES(intptr, int*);
522// CHECK-LABEL: @test_intptr_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000523// CHECK: %braces = alloca i32*, align [[ALIGN:[0-9]*]]
524// CHECK-NEXT: store i32* null, i32** %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000525// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
526
527TEST_UNINIT(intptrptr, int**);
528// CHECK-LABEL: @test_intptrptr_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000529// CHECK: %uninit = alloca i32**, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000530// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000531// PATTERN-LABEL: @test_intptrptr_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000532// PATTERN: store i32** inttoptr ([[IPTRT]] [[IPTR]] to i32**), i32*** %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000533// ZERO-LABEL: @test_intptrptr_uninit()
534// ZERO: store i32** null, i32*** %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000535
536TEST_BRACES(intptrptr, int**);
537// CHECK-LABEL: @test_intptrptr_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000538// CHECK: %braces = alloca i32**, align [[ALIGN:[0-9]*]]
539// CHECK-NEXT: store i32** null, i32*** %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000540// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
541
542TEST_UNINIT(function, void(*)());
543// CHECK-LABEL: @test_function_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000544// CHECK: %uninit = alloca void ()*, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000545// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000546// PATTERN-LABEL: @test_function_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000547// PATTERN: store void ()* inttoptr ([[IPTRT]] [[IPTR]] to void ()*), void ()** %uninit, align
JF Bastien14daa202018-12-18 05:12:21 +0000548// ZERO-LABEL: @test_function_uninit()
549// ZERO: store void ()* null, void ()** %uninit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000550
551TEST_BRACES(function, void(*)());
552// CHECK-LABEL: @test_function_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000553// CHECK: %braces = alloca void ()*, align [[ALIGN:[0-9]*]]
554// CHECK-NEXT: store void ()* null, void ()** %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000555// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
556
557TEST_UNINIT(bool, bool);
558// CHECK-LABEL: @test_bool_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000559// CHECK: %uninit = alloca i8, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000560// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000561// PATTERN-LABEL: @test_bool_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000562// PATTERN: store i8 [[I8]], i8* %uninit, align 1
JF Bastien14daa202018-12-18 05:12:21 +0000563// ZERO-LABEL: @test_bool_uninit()
564// ZERO: store i8 0, i8* %uninit, align 1
JF Bastienc70f65e2018-08-07 03:12:52 +0000565
566TEST_BRACES(bool, bool);
567// CHECK-LABEL: @test_bool_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000568// CHECK: %braces = alloca i8, align [[ALIGN:[0-9]*]]
569// CHECK-NEXT: store i8 0, i8* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000570// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
571
572
573TEST_UNINIT(empty, empty);
574// CHECK-LABEL: @test_empty_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000575// CHECK: %uninit = alloca %struct.empty, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000576// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000577// PATTERN-LABEL: @test_empty_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000578// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_empty_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000579// PATTERN-O1: store i8 [[I8]], {{.*}} align 1
JF Bastien14daa202018-12-18 05:12:21 +0000580// ZERO-LABEL: @test_empty_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000581// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
582// ZERO-O1: store i8 0, {{.*}} align 1
JF Bastienc70f65e2018-08-07 03:12:52 +0000583
584TEST_BRACES(empty, empty);
585// CHECK-LABEL: @test_empty_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000586// CHECK: %braces = alloca %struct.empty, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000587// CHECK-NEXT: bitcast
588// CHECK-NEXT: call void @llvm.memcpy
589// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
590
591TEST_UNINIT(small, small);
592// CHECK-LABEL: @test_small_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000593// CHECK: %uninit = alloca %struct.small, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000594// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000595// PATTERN-LABEL: @test_small_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000596// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_small_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000597// PATTERN-O1: store i8 [[I8]], {{.*}} align 1
JF Bastien14daa202018-12-18 05:12:21 +0000598// ZERO-LABEL: @test_small_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000599// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
600// ZERO-O1: store i8 0, {{.*}} align 1
JF Bastienc70f65e2018-08-07 03:12:52 +0000601
602TEST_BRACES(small, small);
603// CHECK-LABEL: @test_small_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000604// CHECK: %braces = alloca %struct.small, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000605// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +0000606// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 1, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +0000607// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
608
JF Bastien14daa202018-12-18 05:12:21 +0000609TEST_CUSTOM(small, small, { 42 });
JF Bastienc70f65e2018-08-07 03:12:52 +0000610// CHECK-LABEL: @test_small_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000611// CHECK: %custom = alloca %struct.small, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000612// CHECK-NEXT: bitcast
613// CHECK-NEXT: call void @llvm.memcpy
614// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
615
616TEST_UNINIT(smallinit, smallinit);
617// CHECK-LABEL: @test_smallinit_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000618// CHECK: %uninit = alloca %struct.smallinit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000619// CHECK-NEXT: call void @{{.*}}smallinit{{.*}}%uninit)
620// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
621
622TEST_BRACES(smallinit, smallinit);
623// CHECK-LABEL: @test_smallinit_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000624// CHECK: %braces = alloca %struct.smallinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000625// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallinit, %struct.smallinit* %braces, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000626// CHECK-NEXT: store i8 42, i8* %[[C]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000627// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
628
629TEST_CUSTOM(smallinit, smallinit, { 100 });
630// CHECK-LABEL: @test_smallinit_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000631// CHECK: %custom = alloca %struct.smallinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000632// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallinit, %struct.smallinit* %custom, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000633// CHECK-NEXT: store i8 100, i8* %[[C]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000634// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
635
636TEST_UNINIT(smallpartinit, smallpartinit);
637// CHECK-LABEL: @test_smallpartinit_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000638// CHECK: %uninit = alloca %struct.smallpartinit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000639// CHECK-NEXT: call void @{{.*}}smallpartinit{{.*}}%uninit)
640// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000641// PATTERN-LABEL: @test_smallpartinit_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000642// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_smallpartinit_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000643// PATTERN-O1: store i8 [[I8]], {{.*}} align 1
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000644// PATTERN-O1: store i8 42, {{.*}} align 1
JF Bastien14daa202018-12-18 05:12:21 +0000645// ZERO-LABEL: @test_smallpartinit_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000646// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
Leonard Chanf6630922019-06-21 16:03:06 +0000647// ZERO-O1-LEGACY: store i16 0, i16* %uninit, align 2
648// ZERO-O1-NEWPM: store i16 42, i16* %uninit, align 2
JF Bastienc70f65e2018-08-07 03:12:52 +0000649
650TEST_BRACES(smallpartinit, smallpartinit);
651// CHECK-LABEL: @test_smallpartinit_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000652// CHECK: %braces = alloca %struct.smallpartinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000653// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %braces, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000654// CHECK-NEXT: store i8 42, i8* %[[C]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000655// CHECK-NEXT: %[[D:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %braces, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +0000656// CHECK-NEXT: store i8 0, i8* %[[D]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000657// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
658
659TEST_CUSTOM(smallpartinit, smallpartinit, { 100, 42 });
660// CHECK-LABEL: @test_smallpartinit_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000661// CHECK: %custom = alloca %struct.smallpartinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000662// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %custom, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000663// CHECK-NEXT: store i8 100, i8* %[[C]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000664// CHECK-NEXT: %[[D:[^ ]*]] = getelementptr inbounds %struct.smallpartinit, %struct.smallpartinit* %custom, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +0000665// CHECK-NEXT: store i8 42, i8* %[[D]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000666// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
667
668TEST_UNINIT(nullinit, nullinit);
669// CHECK-LABEL: @test_nullinit_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000670// CHECK: %uninit = alloca %struct.nullinit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000671// CHECK-NEXT: call void @{{.*}}nullinit{{.*}}%uninit)
672// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
673
674TEST_BRACES(nullinit, nullinit);
675// CHECK-LABEL: @test_nullinit_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000676// CHECK: %braces = alloca %struct.nullinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000677// CHECK-NEXT: %[[N:[^ ]*]] = getelementptr inbounds %struct.nullinit, %struct.nullinit* %braces, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000678// CHECK-NEXT: store i8* null, i8** %[[N]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000679// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
680
681TEST_CUSTOM(nullinit, nullinit, { (char*)"derp" });
682// CHECK-LABEL: @test_nullinit_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000683// CHECK: %custom = alloca %struct.nullinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000684// CHECK-NEXT: %[[N:[^ ]*]] = getelementptr inbounds %struct.nullinit, %struct.nullinit* %custom, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000685// CHECK-NEXT: store i8* getelementptr inbounds {{.*}}, i8** %[[N]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000686// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
687
688TEST_UNINIT(padded, padded);
689// CHECK-LABEL: @test_padded_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000690// CHECK: %uninit = alloca %struct.padded, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000691// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000692// PATTERN-LABEL: @test_padded_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000693// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_padded_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000694// PATTERN-O1: store i64 [[I64]], i64* %uninit, align 8
JF Bastien14daa202018-12-18 05:12:21 +0000695// ZERO-LABEL: @test_padded_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000696// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
697// ZERO-O1: store i64 0, i64* %uninit, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +0000698
699TEST_BRACES(padded, padded);
700// CHECK-LABEL: @test_padded_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000701// CHECK: %braces = alloca %struct.padded, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000702// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +0000703// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 8, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +0000704// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
705
706TEST_CUSTOM(padded, padded, { 42, 13371337 });
707// CHECK-LABEL: @test_padded_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000708// CHECK: %custom = alloca %struct.padded, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000709// CHECK-NEXT: bitcast
710// CHECK-NEXT: call void @llvm.memcpy
711// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
712
713TEST_UNINIT(paddednullinit, paddednullinit);
714// CHECK-LABEL: @test_paddednullinit_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000715// CHECK: %uninit = alloca %struct.paddednullinit, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000716// CHECK-NEXT: call void @{{.*}}paddednullinit{{.*}}%uninit)
717// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000718// PATTERN-LABEL: @test_paddednullinit_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000719// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_paddednullinit_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000720// PATTERN-O1-LEGACY: store i64 [[I64]], i64* %uninit, align 8
Leonard Chanf6630922019-06-21 16:03:06 +0000721// PATTERN-O1-NEWPM: store i64 2863311360, i64* %uninit, align 8
JF Bastien14daa202018-12-18 05:12:21 +0000722// ZERO-LABEL: @test_paddednullinit_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000723// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
724// ZERO-O1: store i64 0, i64* %uninit, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +0000725
726TEST_BRACES(paddednullinit, paddednullinit);
727// CHECK-LABEL: @test_paddednullinit_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000728// CHECK: %braces = alloca %struct.paddednullinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000729// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %braces, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000730// CHECK-NEXT: store i8 0, i8* %[[C]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000731// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %braces, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +0000732// CHECK-NEXT: store i32 0, i32* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000733// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
734
735TEST_CUSTOM(paddednullinit, paddednullinit, { 42, 13371337 });
736// CHECK-LABEL: @test_paddednullinit_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000737// CHECK: %custom = alloca %struct.paddednullinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000738// CHECK-NEXT: %[[C:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %custom, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +0000739// CHECK-NEXT: store i8 42, i8* %[[C]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000740// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.paddednullinit, %struct.paddednullinit* %custom, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +0000741// CHECK-NEXT: store i32 13371337, i32* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000742// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
743
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000744TEST_UNINIT(paddedpacked, paddedpacked);
745// CHECK-LABEL: @test_paddedpacked_uninit()
746// CHECK: %uninit = alloca %struct.paddedpacked, align
747// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
748// PATTERN-LABEL: @test_paddedpacked_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000749// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_paddedpacked_uninit.uninit
750// PATTERN-O1: %[[C:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 0
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000751// PATTERN-O1 store i8 [[I8]], i8* %[[C]], align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000752// PATTERN-O1: %[[I:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 1
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000753// PATTERN-O1: store i32 [[I32]], i32* %[[I]], align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000754
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000755// ZERO-LABEL: @test_paddedpacked_uninit()
756// ZERO: call void @llvm.memset{{.*}}, i8 0,
757
758TEST_BRACES(paddedpacked, paddedpacked);
759// CHECK-LABEL: @test_paddedpacked_braces()
760// CHECK: %braces = alloca %struct.paddedpacked, align [[ALIGN:[0-9]*]]
761// CHECK-NEXT: bitcast
762// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 5, i1 false)
763// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
764
765TEST_CUSTOM(paddedpacked, paddedpacked, { 42, 13371337 });
766// CHECK-LABEL: @test_paddedpacked_custom()
767// CHECK: %custom = alloca %struct.paddedpacked, align
768// CHECK-NEXT: bitcast
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000769// CHECK-NEXT: call void @llvm.memcpy{{.*}}({{.*}}@__const.test_paddedpacked_custom.custom
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000770// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
771
772TEST_UNINIT(paddedpackedarray, paddedpackedarray);
773// CHECK-LABEL: @test_paddedpackedarray_uninit()
774// CHECK: %uninit = alloca %struct.paddedpackedarray, align
775// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
776// PATTERN-LABEL: @test_paddedpackedarray_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000777// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_paddedpackedarray_uninit.uninit
778// PATTERN-O1: getelementptr
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000779// PATTERN-O1: call void @llvm.memset{{.*}}({{.*}}i8 [[I8]], i64 10
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000780// ZERO-LABEL: @test_paddedpackedarray_uninit()
781// ZERO: call void @llvm.memset{{.*}}, i8 0,
782
783TEST_BRACES(paddedpackedarray, paddedpackedarray);
784// CHECK-LABEL: @test_paddedpackedarray_braces()
785// CHECK: %braces = alloca %struct.paddedpackedarray, align [[ALIGN:[0-9]*]]
786// CHECK-NEXT: bitcast
787// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 10, i1 false)
788// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
789
790TEST_CUSTOM(paddedpackedarray, paddedpackedarray, { {{ 42, 13371337 }, { 43, 13371338 }} });
791// CHECK-LABEL: @test_paddedpackedarray_custom()
792// CHECK: %custom = alloca %struct.paddedpackedarray, align
793// CHECK-NEXT: bitcast
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000794// CHECK-NEXT: call void @llvm.memcpy{{.*}}({{.*}}@__const.test_paddedpackedarray_custom.custom
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000795// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
796
Peter Collingbourne68b46732019-03-16 19:25:39 +0000797TEST_UNINIT(unpackedinpacked, unpackedinpacked);
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000798// PATTERN-LABEL: @test_unpackedinpacked_uninit()
799// PATTERN-O0: call void @llvm.memcpy{{.*}} 9, i1 false)
Peter Collingbourne68b46732019-03-16 19:25:39 +0000800
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000801TEST_UNINIT(paddednested, paddednested);
802// CHECK-LABEL: @test_paddednested_uninit()
803// CHECK: %uninit = alloca %struct.paddednested, align
804// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
805// PATTERN-LABEL: @test_paddednested_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000806// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_paddednested_uninit.uninit
807// PATTERN-O1: getelementptr
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000808// PATTERN-O1: call void @llvm.memset{{.*}}({{.*}}, i8 [[I8]], i64 16
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000809// ZERO-LABEL: @test_paddednested_uninit()
810// ZERO: call void @llvm.memset{{.*}}, i8 0,
811
812TEST_BRACES(paddednested, paddednested);
813// CHECK-LABEL: @test_paddednested_braces()
814// CHECK: %braces = alloca %struct.paddednested, align [[ALIGN:[0-9]*]]
815// CHECK-NEXT: bitcast
816// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 16, i1 false)
817// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
818
819TEST_CUSTOM(paddednested, paddednested, { { 42, 13371337 }, { 43, 13371338 } });
820// CHECK-LABEL: @test_paddednested_custom()
821// CHECK: %custom = alloca %struct.paddednested, align
822// CHECK-NEXT: bitcast
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000823// CHECK-NEXT: call void @llvm.memcpy{{.*}}({{.*}}@__const.test_paddednested_custom.custom
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000824// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
825
826TEST_UNINIT(paddedpackednested, paddedpackednested);
827// CHECK-LABEL: @test_paddedpackednested_uninit()
828// CHECK: %uninit = alloca %struct.paddedpackednested, align
829// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
830// PATTERN-LABEL: @test_paddedpackednested_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000831// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_paddedpackednested_uninit.uninit
832// PATTERN-O1: getelementptr
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000833// PATTERN-O1: call void @llvm.memset.p0i8.i64(i8* nonnull align 1 %0, i8 [[I8]], i64 10, i1 false
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000834// ZERO-LABEL: @test_paddedpackednested_uninit()
835// ZERO: call void @llvm.memset{{.*}}, i8 0,
836
837TEST_BRACES(paddedpackednested, paddedpackednested);
838// CHECK-LABEL: @test_paddedpackednested_braces()
839// CHECK: %braces = alloca %struct.paddedpackednested, align [[ALIGN:[0-9]*]]
840// CHECK-NEXT: bitcast
841// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 10, i1 false)
842// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
843
844TEST_CUSTOM(paddedpackednested, paddedpackednested, { { 42, 13371337 }, { 43, 13371338 } });
845// CHECK-LABEL: @test_paddedpackednested_custom()
846// CHECK: %custom = alloca %struct.paddedpackednested, align
847// CHECK-NEXT: bitcast
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000848// CHECK-NEXT: call void @llvm.memcpy{{.*}}({{.*}}@__const.test_paddedpackednested_custom.custom
Alexander Potapenko4f7bc0e2019-02-26 10:46:21 +0000849// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
850
JF Bastienc70f65e2018-08-07 03:12:52 +0000851TEST_UNINIT(bitfield, bitfield);
852// CHECK-LABEL: @test_bitfield_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000853// CHECK: %uninit = alloca %struct.bitfield, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000854// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000855// PATTERN-LABEL: @test_bitfield_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000856// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_bitfield_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000857// PATTERN-O1: store i32 [[I32]], i32* %uninit, align 4
JF Bastien14daa202018-12-18 05:12:21 +0000858// ZERO-LABEL: @test_bitfield_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000859// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
860// ZERO-O1: store i32 0, i32* %uninit, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +0000861
862TEST_BRACES(bitfield, bitfield);
863// CHECK-LABEL: @test_bitfield_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000864// CHECK: %braces = alloca %struct.bitfield, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000865// CHECK-NEXT: bitcast
866// CHECK-NEXT: call void @llvm.memcpy
867// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
868
869TEST_CUSTOM(bitfield, bitfield, { 4, 1 });
870// CHECK-LABEL: @test_bitfield_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000871// CHECK: %custom = alloca %struct.bitfield, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000872// CHECK-NEXT: bitcast
873// CHECK-NEXT: call void @llvm.memcpy
874// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
875
876TEST_UNINIT(bitfieldaligned, bitfieldaligned);
877// CHECK-LABEL: @test_bitfieldaligned_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000878// CHECK: %uninit = alloca %struct.bitfieldaligned, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000879// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000880// PATTERN-LABEL: @test_bitfieldaligned_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000881// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_bitfieldaligned_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000882// PATTERN-O1: store i64 [[IPTR]], i64* %uninit, align 8
JF Bastien14daa202018-12-18 05:12:21 +0000883// ZERO-LABEL: @test_bitfieldaligned_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000884// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
885// ZERO-O1: store i64 0, i64* %uninit, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +0000886
887TEST_BRACES(bitfieldaligned, bitfieldaligned);
888// CHECK-LABEL: @test_bitfieldaligned_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000889// CHECK: %braces = alloca %struct.bitfieldaligned, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000890// CHECK-NEXT: bitcast
891// CHECK-NEXT: call void @llvm.memcpy
892// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
893
894TEST_CUSTOM(bitfieldaligned, bitfieldaligned, { 4, 1 });
895// CHECK-LABEL: @test_bitfieldaligned_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000896// CHECK: %custom = alloca %struct.bitfieldaligned, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000897// CHECK-NEXT: bitcast
898// CHECK-NEXT: call void @llvm.memcpy
899// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
900
901TEST_UNINIT(big, big);
902// CHECK-LABEL: @test_big_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000903// CHECK: %uninit = alloca %struct.big, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000904// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000905// PATTERN-LABEL: @test_big_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000906// PATTERN: call void @llvm.memset{{.*}}, i8 [[I8]],
JF Bastien14daa202018-12-18 05:12:21 +0000907// ZERO-LABEL: @test_big_uninit()
908// ZERO: call void @llvm.memset{{.*}}, i8 0,
JF Bastienc70f65e2018-08-07 03:12:52 +0000909
910TEST_BRACES(big, big);
911// CHECK-LABEL: @test_big_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000912// CHECK: %braces = alloca %struct.big, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000913// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +0000914// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 104, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +0000915// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
916
917TEST_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 });
918// CHECK-LABEL: @test_big_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000919// CHECK: %custom = alloca %struct.big, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000920// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +0000921// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 -86, i64 104, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +0000922// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
923
924TEST_UNINIT(arraytail, arraytail);
925// CHECK-LABEL: @test_arraytail_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000926// CHECK: %uninit = alloca %struct.arraytail, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000927// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000928// PATTERN-LABEL: @test_arraytail_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000929// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_arraytail_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000930// PATTERN-O1: store i32 [[I32]], {{.*}} align 4
JF Bastien14daa202018-12-18 05:12:21 +0000931// ZERO-LABEL: @test_arraytail_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000932// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
933// ZERO-O1: store i32 0, {{.*}} align 4
JF Bastienc70f65e2018-08-07 03:12:52 +0000934
935TEST_BRACES(arraytail, arraytail);
936// CHECK-LABEL: @test_arraytail_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000937// CHECK: %braces = alloca %struct.arraytail, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000938// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +0000939// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 4, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +0000940// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
941
942TEST_CUSTOM(arraytail, arraytail, { 0xdead });
943// CHECK-LABEL: @test_arraytail_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000944// CHECK: %custom = alloca %struct.arraytail, align
JF Bastienc70f65e2018-08-07 03:12:52 +0000945// CHECK-NEXT: bitcast
946// CHECK-NEXT: call void @llvm.memcpy
947// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
948
949
950TEST_UNINIT(int0, int[0]);
951// CHECK-LABEL: @test_int0_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000952// CHECK: %uninit = alloca [0 x i32], align
JF Bastienc70f65e2018-08-07 03:12:52 +0000953// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000954// PATTERN-LABEL: @test_int0_uninit()
955// PATTERN: %uninit = alloca [0 x i32], align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000956// PATTERN-O0-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000957// ZERO-LABEL: @test_int0_uninit()
958// ZERO: %uninit = alloca [0 x i32], align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000959// ZERO-O0-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastienc70f65e2018-08-07 03:12:52 +0000960
961TEST_BRACES(int0, int[0]);
962// CHECK-LABEL: @test_int0_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000963// CHECK: %braces = alloca [0 x i32], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000964// CHECK-NEXT: bitcast
JF Bastienc70f65e2018-08-07 03:12:52 +0000965// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
966
967TEST_UNINIT(int1, int[1]);
968// CHECK-LABEL: @test_int1_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000969// CHECK: %uninit = alloca [1 x i32], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000970// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000971// PATTERN-LABEL: @test_int1_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000972// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_int1_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000973// PATTERN-O1: store i32 [[I32]], {{.*}} align 4
JF Bastien14daa202018-12-18 05:12:21 +0000974// ZERO-LABEL: @test_int1_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +0000975// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
976// ZERO-O1: store i32 0, {{.*}} align 4
JF Bastienc70f65e2018-08-07 03:12:52 +0000977
978TEST_BRACES(int1, int[1]);
979// CHECK-LABEL: @test_int1_braces()
JF Bastiencc365c32018-08-07 22:43:44 +0000980// CHECK: %braces = alloca [1 x i32], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +0000981// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +0000982// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 4, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +0000983// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
984
985TEST_CUSTOM(int1, int[1], { 0x33333333 });
986// CHECK-LABEL: @test_int1_custom()
JF Bastiencc365c32018-08-07 22:43:44 +0000987// CHECK: %custom = alloca [1 x i32], align
JF Bastienc70f65e2018-08-07 03:12:52 +0000988// CHECK-NEXT: bitcast
989// CHECK-NEXT: call void @llvm.memcpy
990// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
991
992TEST_UNINIT(int64, int[64]);
993// CHECK-LABEL: @test_int64_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +0000994// CHECK: %uninit = alloca [64 x i32], align
JF Bastienc70f65e2018-08-07 03:12:52 +0000995// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +0000996// PATTERN-LABEL: @test_int64_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +0000997// PATTERN: call void @llvm.memset{{.*}}, i8 [[I8]],
JF Bastien14daa202018-12-18 05:12:21 +0000998// ZERO-LABEL: @test_int64_uninit()
999// ZERO: call void @llvm.memset{{.*}}, i8 0,
JF Bastienc70f65e2018-08-07 03:12:52 +00001000
1001TEST_BRACES(int64, int[64]);
1002// CHECK-LABEL: @test_int64_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001003// CHECK: %braces = alloca [64 x i32], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001004// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001005// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 256, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001006// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1007
1008TEST_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 });
1009// CHECK-LABEL: @test_int64_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001010// CHECK: %custom = alloca [64 x i32], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001011// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001012// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 17, i64 256, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001013// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1014
1015TEST_UNINIT(bool4, bool[4]);
1016// CHECK-LABEL: @test_bool4_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001017// CHECK: %uninit = alloca [4 x i8], align
JF Bastienc70f65e2018-08-07 03:12:52 +00001018// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001019// PATTERN-LABEL: @test_bool4_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001020// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_bool4_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001021// PATTERN-O1: store i32 [[I32]], i32* %uninit, align 4
JF Bastien14daa202018-12-18 05:12:21 +00001022// ZERO-LABEL: @test_bool4_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001023// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1024// ZERO-O1: store i32 0, i32* %uninit, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001025
1026TEST_BRACES(bool4, bool[4]);
1027// CHECK-LABEL: @test_bool4_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001028// CHECK: %braces = alloca [4 x i8], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001029// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001030// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 4, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001031// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1032
1033TEST_CUSTOM(bool4, bool[4], { true, true, true, true });
1034// CHECK-LABEL: @test_bool4_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001035// CHECK: %custom = alloca [4 x i8], align
JF Bastienc70f65e2018-08-07 03:12:52 +00001036// CHECK-NEXT: bitcast
1037// CHECK-NEXT: call void @llvm.memcpy
1038// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1039
1040TEST_UNINIT(intptr4, int*[4]);
JF Bastienb5e5bc72019-03-08 01:26:49 +00001041// CHECK-LABEL: @test_intptr4_uninit()
1042// CHECK: %uninit = alloca [4 x i32*], align
1043// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
1044// PATTERN-O1-LABEL: @test_intptr4_uninit()
1045// PATTERN-O1: %1 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 0
1046// PATTERN-O1-NEXT: store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %1, align 16
1047// PATTERN-O1-NEXT: %2 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 1
1048// PATTERN-O1-NEXT: store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %2, align 8
1049// PATTERN-O1-NEXT: %3 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 2
1050// PATTERN-O1-NEXT: store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %3, align 16
1051// PATTERN-O1-NEXT: %4 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 3
1052// PATTERN-O1-NEXT: store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %4, align 8
1053// ZERO-LABEL: @test_intptr4_uninit()
1054// ZERO: call void @llvm.memset{{.*}}, i8 0,
JF Bastienc70f65e2018-08-07 03:12:52 +00001055
1056TEST_BRACES(intptr4, int*[4]);
1057// CHECK-LABEL: @test_intptr4_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001058// CHECK: %braces = alloca [4 x i32*], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001059// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001060// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 32, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001061// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1062
1063 TEST_CUSTOM(intptr4, int*[4], = { (int*)0x22222222, (int*)0x22222222, (int*)0x22222222, (int*)0x22222222 });
1064// CHECK-LABEL: @test_intptr4_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001065// CHECK: %custom = alloca [4 x i32*], align
JF Bastienc70f65e2018-08-07 03:12:52 +00001066// CHECK-NEXT: bitcast
1067// CHECK-NEXT: call void @llvm.memcpy
1068// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1069
1070TEST_UNINIT(tailpad4, tailpad[4]);
1071// CHECK-LABEL: @test_tailpad4_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001072// CHECK: %uninit = alloca [4 x %struct.tailpad], align
JF Bastienc70f65e2018-08-07 03:12:52 +00001073// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001074// PATTERN-LABEL: @test_tailpad4_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001075// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_tailpad4_uninit.uninit
1076// PATTERN-O1: bitcast
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001077// PATTERN-O1: call void @llvm.memset{{.*}}({{.*}}0, i8 [[I8]], i64 16
JF Bastien14daa202018-12-18 05:12:21 +00001078// ZERO-LABEL: @test_tailpad4_uninit()
1079// ZERO: call void @llvm.memset{{.*}}, i8 0,
JF Bastienc70f65e2018-08-07 03:12:52 +00001080
1081TEST_BRACES(tailpad4, tailpad[4]);
1082// CHECK-LABEL: @test_tailpad4_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001083// CHECK: %braces = alloca [4 x %struct.tailpad], align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001084// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001085// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 16, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001086// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1087
JF Bastienfe2ea822018-08-08 17:05:17 +00001088TEST_CUSTOM(tailpad4, tailpad[4], { {257, 1}, {257, 1}, {257, 1}, {257, 1} });
JF Bastienc70f65e2018-08-07 03:12:52 +00001089// CHECK-LABEL: @test_tailpad4_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001090// CHECK: %custom = alloca [4 x %struct.tailpad], align
JF Bastienc70f65e2018-08-07 03:12:52 +00001091// CHECK-NEXT: bitcast
1092// CHECK-NEXT: call void @llvm.memcpy
1093// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1094
JF Bastienfe2ea822018-08-08 17:05:17 +00001095TEST_UNINIT(tailpad9, tailpad[9]);
1096// CHECK-LABEL: @test_tailpad9_uninit()
1097// CHECK: %uninit = alloca [9 x %struct.tailpad], align
1098// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001099// PATTERN-LABEL: @test_tailpad9_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001100// PATTERN-O0: call void @llvm.memset{{.*}}, i8 [[I8]],
JF Bastien14daa202018-12-18 05:12:21 +00001101// ZERO-LABEL: @test_tailpad9_uninit()
1102// ZERO: call void @llvm.memset{{.*}}, i8 0,
JF Bastienfe2ea822018-08-08 17:05:17 +00001103
1104TEST_BRACES(tailpad9, tailpad[9]);
1105// CHECK-LABEL: @test_tailpad9_braces()
1106// CHECK: %braces = alloca [9 x %struct.tailpad], align [[ALIGN:[0-9]*]]
1107// CHECK-NEXT: bitcast
1108// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 36, i1 false)
1109// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1110
1111TEST_CUSTOM(tailpad9, tailpad[9], { {257, 1}, {257, 1}, {257, 1}, {257, 1}, {257, 1}, {257, 1}, {257, 1}, {257, 1}, {257, 1} });
1112// CHECK-LABEL: @test_tailpad9_custom()
1113// CHECK: %custom = alloca [9 x %struct.tailpad], align [[ALIGN:[0-9]*]]
1114// CHECK-NEXT: bitcast
1115// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 1, i64 36, i1 false)
1116// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1117
JF Bastienc70f65e2018-08-07 03:12:52 +00001118
1119TEST_UNINIT(atomicbool, _Atomic(bool));
1120// CHECK-LABEL: @test_atomicbool_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001121// CHECK: %uninit = alloca i8, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001122// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001123// PATTERN-LABEL: @test_atomicbool_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001124// PATTERN: store i8 [[I8]], i8* %uninit, align 1
JF Bastien14daa202018-12-18 05:12:21 +00001125// ZERO-LABEL: @test_atomicbool_uninit()
1126// ZERO: store i8 0, i8* %uninit, align 1
JF Bastienc70f65e2018-08-07 03:12:52 +00001127
1128TEST_UNINIT(atomicint, _Atomic(int));
1129// CHECK-LABEL: @test_atomicint_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001130// CHECK: %uninit = alloca i32, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001131// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001132// PATTERN-LABEL: @test_atomicint_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001133// PATTERN: store i32 [[I32]], i32* %uninit, align 4
JF Bastien14daa202018-12-18 05:12:21 +00001134// ZERO-LABEL: @test_atomicint_uninit()
1135// ZERO: store i32 0, i32* %uninit, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001136
1137TEST_UNINIT(atomicdouble, _Atomic(double));
1138// CHECK-LABEL: @test_atomicdouble_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001139// CHECK: %uninit = alloca double, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001140// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001141// PATTERN-LABEL: @test_atomicdouble_uninit()
1142// PATTERN: store double 0xFFFFFFFFFFFFFFFF, double* %uninit, align 8
1143// ZERO-LABEL: @test_atomicdouble_uninit()
1144// ZERO: store double 0.000000e+00, double* %uninit, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001145
1146TEST_UNINIT(atomicnotlockfree, _Atomic(notlockfree));
1147// CHECK-LABEL: @test_atomicnotlockfree_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001148// CHECK: %uninit = alloca %struct.notlockfree, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001149// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001150// PATTERN-LABEL: @test_atomicnotlockfree_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001151// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_atomicnotlockfree_uninit.uninit
1152// PATTERN-O1: bitcast
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001153// PATTERN-O1: call void @llvm.memset{{.*}}({{.*}}, i8 [[I8]], i64 32
JF Bastien14daa202018-12-18 05:12:21 +00001154// ZERO-LABEL: @test_atomicnotlockfree_uninit()
1155// ZERO: call void @llvm.memset{{.*}}, i8 0,
JF Bastienc70f65e2018-08-07 03:12:52 +00001156
1157TEST_UNINIT(atomicpadded, _Atomic(padded));
1158// CHECK-LABEL: @test_atomicpadded_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001159// CHECK: %uninit = alloca %struct.padded, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001160// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001161// PATTERN-LABEL: @test_atomicpadded_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001162// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_atomicpadded_uninit.uninit
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001163// PATTERN-O1: store i64 [[IPTR]], i64* %uninit, align 8
JF Bastien14daa202018-12-18 05:12:21 +00001164// ZERO-LABEL: @test_atomicpadded_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001165// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1166// ZERO-O1: store i64 0, i64* %uninit, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001167
1168TEST_UNINIT(atomictailpad, _Atomic(tailpad));
1169// CHECK-LABEL: @test_atomictailpad_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001170// CHECK: %uninit = alloca %struct.tailpad, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001171// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001172// PATTERN-LABEL: @test_atomictailpad_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001173// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_atomictailpad_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001174// ZERO-LABEL: @test_atomictailpad_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001175// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1176// ZERO-O1: store i32 0, i32* %uninit, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001177
1178TEST_UNINIT(complexfloat, _Complex float);
1179// CHECK-LABEL: @test_complexfloat_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001180// CHECK: %uninit = alloca { float, float }, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001181// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001182// PATTERN-LABEL: @test_complexfloat_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001183// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_complexfloat_uninit.uninit
1184// PATTERN-O1: %[[F1:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 0
1185// PATTERN-O1 store float 0xFFFFFFFFE0000000, float* %[[F1]], align
1186// PATTERN-O1: %[[F2:[^ ]*]] = getelementptr inbounds {{.*}}%uninit, i64 0, i32 1
1187// PATTERN-O1: store float 0xFFFFFFFFE0000000, float* %[[F2]], align
1188
JF Bastien14daa202018-12-18 05:12:21 +00001189// ZERO-LABEL: @test_complexfloat_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001190// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1191// ZERO-O1: store i64 0, i64* %uninit, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001192
1193TEST_BRACES(complexfloat, _Complex float);
1194// CHECK-LABEL: @test_complexfloat_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001195// CHECK: %braces = alloca { float, float }, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001196// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %braces, i32 0, i32 0
1197// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %braces, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +00001198// CHECK-NEXT: store float 0.000000e+00, float* %[[R]], align [[ALIGN]]
1199// CHECK-NEXT: store float 0.000000e+00, float* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001200// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1201
1202TEST_CUSTOM(complexfloat, _Complex float, { 3.1415926535897932384626433, 3.1415926535897932384626433 });
1203// CHECK-LABEL: @test_complexfloat_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001204// CHECK: %custom = alloca { float, float }, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001205// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %custom, i32 0, i32 0
1206// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { float, float }, { float, float }* %custom, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +00001207// CHECK-NEXT: store float 0x400921FB60000000, float* %[[R]], align [[ALIGN]]
1208// CHECK-NEXT: store float 0x400921FB60000000, float* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001209// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1210
1211TEST_UNINIT(complexdouble, _Complex double);
1212// CHECK-LABEL: @test_complexdouble_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001213// CHECK: %uninit = alloca { double, double }, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001214// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001215// PATTERN-LABEL: @test_complexdouble_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001216// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_complexdouble_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001217// ZERO-LABEL: @test_complexdouble_uninit()
1218// ZERO: call void @llvm.memset{{.*}}, i8 0,
JF Bastienc70f65e2018-08-07 03:12:52 +00001219
1220TEST_BRACES(complexdouble, _Complex double);
1221// CHECK-LABEL: @test_complexdouble_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001222// CHECK: %braces = alloca { double, double }, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001223// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %braces, i32 0, i32 0
1224// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %braces, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +00001225// CHECK-NEXT: store double 0.000000e+00, double* %[[R]], align [[ALIGN]]
1226// CHECK-NEXT: store double 0.000000e+00, double* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001227// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1228
1229TEST_CUSTOM(complexdouble, _Complex double, { 3.1415926535897932384626433, 3.1415926535897932384626433 });
1230// CHECK-LABEL: @test_complexdouble_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001231// CHECK: %custom = alloca { double, double }, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001232// CHECK-NEXT: %[[R:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %custom, i32 0, i32 0
1233// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds { double, double }, { double, double }* %custom, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +00001234// CHECK-NEXT: store double 0x400921FB54442D18, double* %[[R]], align [[ALIGN]]
1235// CHECK-NEXT: store double 0x400921FB54442D18, double* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001236// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1237
1238
1239TEST_UNINIT(volatileint, volatile int);
1240// CHECK-LABEL: @test_volatileint_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001241// CHECK: %uninit = alloca i32, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001242// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001243// PATTERN-LABEL: @test_volatileint_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001244// PATTERN: store volatile i32 [[I32]], i32* %uninit, align 4
JF Bastien14daa202018-12-18 05:12:21 +00001245// ZERO-LABEL: @test_volatileint_uninit()
1246// ZERO: store volatile i32 0, i32* %uninit, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001247
1248TEST_BRACES(volatileint, volatile int);
1249// CHECK-LABEL: @test_volatileint_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001250// CHECK: %braces = alloca i32, align [[ALIGN:[0-9]*]]
1251// CHECK-NEXT: store volatile i32 0, i32* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001252// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1253
1254TEST_UNINIT(semivolatile, semivolatile);
1255// CHECK-LABEL: @test_semivolatile_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001256// CHECK: %uninit = alloca %struct.semivolatile, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001257// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001258// PATTERN-LABEL: @test_semivolatile_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001259// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_semivolatile_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001260// ZERO-LABEL: @test_semivolatile_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001261// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1262// ZERO-O1: store i64 0, i64* %uninit, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001263
1264TEST_BRACES(semivolatile, semivolatile);
1265// CHECK-LABEL: @test_semivolatile_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001266// CHECK: %braces = alloca %struct.semivolatile, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001267// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001268// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 8, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001269// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1270
1271TEST_CUSTOM(semivolatile, semivolatile, { 0x44444444, 0x44444444 });
1272// CHECK-LABEL: @test_semivolatile_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001273// CHECK: %custom = alloca %struct.semivolatile, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001274// CHECK-O0: bitcast
1275// CHECK-O0: call void @llvm.memcpy
1276// CHECK-O0: call void @{{.*}}used{{.*}}%custom)
1277// CHECK-O1: store i64 4919131752989213764, i64* %custom, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001278
1279TEST_UNINIT(semivolatileinit, semivolatileinit);
1280// CHECK-LABEL: @test_semivolatileinit_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001281// CHECK: %uninit = alloca %struct.semivolatileinit, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001282// CHECK-NEXT: call void @{{.*}}semivolatileinit{{.*}}%uninit)
1283// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
1284
1285TEST_BRACES(semivolatileinit, semivolatileinit);
1286// CHECK-LABEL: @test_semivolatileinit_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001287// CHECK: %braces = alloca %struct.semivolatileinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001288// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %braces, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +00001289// CHECK-NEXT: store i32 286331153, i32* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001290// CHECK-NEXT: %[[VI:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %braces, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +00001291// CHECK-NEXT: store volatile i32 286331153, i32* %[[VI]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001292// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1293
1294TEST_CUSTOM(semivolatileinit, semivolatileinit, { 0x44444444, 0x44444444 });
1295// CHECK-LABEL: @test_semivolatileinit_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001296// CHECK: %custom = alloca %struct.semivolatileinit, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001297// CHECK-NEXT: %[[I:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %custom, i32 0, i32 0
JF Bastiencc365c32018-08-07 22:43:44 +00001298// CHECK-NEXT: store i32 1145324612, i32* %[[I]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001299// CHECK-NEXT: %[[VI:[^ ]*]] = getelementptr inbounds %struct.semivolatileinit, %struct.semivolatileinit* %custom, i32 0, i32 1
JF Bastiencc365c32018-08-07 22:43:44 +00001300// CHECK-NEXT: store volatile i32 1145324612, i32* %[[VI]], align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001301// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1302
1303
1304TEST_UNINIT(base, base);
1305// CHECK-LABEL: @test_base_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001306// CHECK: %uninit = alloca %struct.base, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001307// CHECK-NEXT: call void @{{.*}}base{{.*}}%uninit)
1308// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001309// PATTERN-LABEL: @test_base_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001310// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_base_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001311// ZERO-LABEL: @test_base_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001312// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
Leonard Chanf6630922019-06-21 16:03:06 +00001313// ZERO-O1-LEGACY: store i64 0, {{.*}} align 8
1314// ZERO-O1-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV4base, i64 0, inrange i32 0, i64 2) to i32 (...)**), {{.*}}, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001315
1316TEST_BRACES(base, base);
1317// CHECK-LABEL: @test_base_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001318// CHECK: %braces = alloca %struct.base, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001319// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001320// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 8, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001321// CHECK-NEXT: call void @{{.*}}base{{.*}}%braces)
1322// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1323
1324TEST_UNINIT(derived, derived);
1325// CHECK-LABEL: @test_derived_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001326// CHECK: %uninit = alloca %struct.derived, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001327// CHECK-NEXT: call void @{{.*}}derived{{.*}}%uninit)
1328// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001329// PATTERN-LABEL: @test_derived_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001330// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_derived_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001331// ZERO-LABEL: @test_derived_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001332// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
Leonard Chanf6630922019-06-21 16:03:06 +00001333// ZERO-O1-LEGACY: store i64 0, {{.*}} align 8
1334// ZERO-O1-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x i8*] }, { [4 x i8*] }* @_ZTV7derived, i64 0, inrange i32 0, i64 2) to i32 (...)**), {{.*}} align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001335
1336TEST_BRACES(derived, derived);
1337// CHECK-LABEL: @test_derived_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001338// CHECK: %braces = alloca %struct.derived, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001339// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001340// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 8, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001341// CHECK-NEXT: call void @{{.*}}derived{{.*}}%braces)
1342// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1343
1344TEST_UNINIT(virtualderived, virtualderived);
1345// CHECK-LABEL: @test_virtualderived_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001346// CHECK: %uninit = alloca %struct.virtualderived, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001347// CHECK-NEXT: call void @{{.*}}virtualderived{{.*}}%uninit)
1348// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001349// PATTERN-LABEL: @test_virtualderived_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001350// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_virtualderived_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001351// ZERO-LABEL: @test_virtualderived_uninit()
Leonard Chanf6630922019-06-21 16:03:06 +00001352// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1353// ZERO-O1-LEGACY: call void @llvm.memset{{.*}}, i8 0,
1354// ZERO-O1-NEWPM: [[FIELD1:%.*]] = getelementptr inbounds %struct.virtualderived, %struct.virtualderived* %uninit, i64 0, i32 1, i32 0, i32 0
1355// ZERO-O1-NEWPM: [[FIELD0:%.*]] = getelementptr inbounds %struct.virtualderived, %struct.virtualderived* %uninit, i64 0, i32 0, i32 0
1356// ZERO-O1-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [7 x i8*], [5 x i8*] }, { [7 x i8*], [5 x i8*] }* @_ZTV14virtualderived, i64 0, inrange i32 0, i64 5) to i32 (...)**), i32 (...)*** [[FIELD0]], align 8
1357// ZERO-O1-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [7 x i8*], [5 x i8*] }, { [7 x i8*], [5 x i8*] }* @_ZTV14virtualderived, i64 0, inrange i32 1, i64 3) to i32 (...)**), i32 (...)*** [[FIELD1]], align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001358
1359TEST_BRACES(virtualderived, virtualderived);
1360// CHECK-LABEL: @test_virtualderived_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001361// CHECK: %braces = alloca %struct.virtualderived, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001362// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001363// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 16, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001364// CHECK-NEXT: call void @{{.*}}virtualderived{{.*}}%braces)
1365// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1366
1367
1368TEST_UNINIT(matching, matching);
1369// CHECK-LABEL: @test_matching_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001370// CHECK: %uninit = alloca %union.matching, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001371// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001372// PATTERN-LABEL: @test_matching_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001373// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_matching_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001374// ZERO-LABEL: @test_matching_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001375// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1376// ZERO-O1: store i32 0, {{.*}} align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001377
1378TEST_BRACES(matching, matching);
1379// CHECK-LABEL: @test_matching_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001380// CHECK: %braces = alloca %union.matching, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001381// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001382// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 4, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001383// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1384
1385TEST_CUSTOM(matching, matching, { .f = 0xf00f });
1386// CHECK-LABEL: @test_matching_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001387// CHECK: %custom = alloca %union.matching, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001388// CHECK-O0: bitcast
1389// CHECK-O0: call void @llvm.memcpy
1390// CHECK-O0: call void @{{.*}}used{{.*}}%custom)
1391// CHECK-O1: getelementptr
1392// CHECK-O1: store i32 1198526208, i32* {{.*}}, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001393
1394TEST_UNINIT(matchingreverse, matchingreverse);
1395// CHECK-LABEL: @test_matchingreverse_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001396// CHECK: %uninit = alloca %union.matchingreverse, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001397// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001398// PATTERN-LABEL: @test_matchingreverse_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001399// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_matchingreverse_uninit.uninit
1400// PATTERN-O1: store float 0xFFFFFFFFE0000000
JF Bastien14daa202018-12-18 05:12:21 +00001401// ZERO-LABEL: @test_matchingreverse_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001402// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1403// ZERO-O1: store i32 0, {{.*}} align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001404
1405TEST_BRACES(matchingreverse, matchingreverse);
1406// CHECK-LABEL: @test_matchingreverse_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001407// CHECK: %braces = alloca %union.matchingreverse, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001408// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001409// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 4, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001410// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1411
1412TEST_CUSTOM(matchingreverse, matchingreverse, { .i = 0xf00f });
1413// CHECK-LABEL: @test_matchingreverse_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001414// CHECK: %custom = alloca %union.matchingreverse, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001415// CHECK-O0: bitcast
1416// CHECK-O0: call void @llvm.memcpy
1417// CHECK-O0: call void @{{.*}}used{{.*}}%custom)
1418// CHECK-O1: store i32 61455, i32* %1, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001419
1420TEST_UNINIT(unmatched, unmatched);
1421// CHECK-LABEL: @test_unmatched_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001422// CHECK: %uninit = alloca %union.unmatched, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001423// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001424// PATTERN-LABEL: @test_unmatched_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001425// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_unmatched_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001426// ZERO-LABEL: @test_unmatched_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001427// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1428// ZERO-O1: store i32 0, {{.*}} align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001429
1430TEST_BRACES(unmatched, unmatched);
1431// CHECK-LABEL: @test_unmatched_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001432// CHECK: %braces = alloca %union.unmatched, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001433// CHECK-NEXT: bitcast
1434// CHECK-NEXT: call void @llvm.memcpy
1435// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1436
1437TEST_CUSTOM(unmatched, unmatched, { .i = 0x3badbeef });
1438// CHECK-LABEL: @test_unmatched_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001439// CHECK: %custom = alloca %union.unmatched, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001440// CHECK-O0: bitcast
1441// CHECK-O0: call void @llvm.memcpy
1442// CHECK-O0: call void @{{.*}}used{{.*}}%custom)
1443// CHECK-O1: store i32 1001242351, i32* {{.*}}, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001444
1445TEST_UNINIT(unmatchedreverse, unmatchedreverse);
1446// CHECK-LABEL: @test_unmatchedreverse_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001447// CHECK: %uninit = alloca %union.unmatchedreverse, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001448// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001449// PATTERN-LABEL: @test_unmatchedreverse_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001450// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_unmatchedreverse_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001451// ZERO-LABEL: @test_unmatchedreverse_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001452// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1453// ZERO-O1: store i32 0, {{.*}} align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001454
1455TEST_BRACES(unmatchedreverse, unmatchedreverse);
1456// CHECK-LABEL: @test_unmatchedreverse_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001457// CHECK: %braces = alloca %union.unmatchedreverse, align [[ALIGN:[0-9]*]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001458// CHECK-NEXT: bitcast
JF Bastiencc365c32018-08-07 22:43:44 +00001459// CHECK-NEXT: call void @llvm.memset{{.*}}(i8* align [[ALIGN]] %{{.*}}, i8 0, i64 4, i1 false)
JF Bastienc70f65e2018-08-07 03:12:52 +00001460// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1461
1462TEST_CUSTOM(unmatchedreverse, unmatchedreverse, { .c = 42 });
1463// CHECK-LABEL: @test_unmatchedreverse_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001464// CHECK: %custom = alloca %union.unmatchedreverse, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001465// CHECK-O0: bitcast
1466// CHECK-O0: call void @llvm.memcpy
1467// CHECK-O0: call void @{{.*}}used{{.*}}%custom)
1468// PATTERN-O1: store i32 -1431655894, i32* {{.*}}, align 4
1469// ZERO-O1: store i32 42, i32* {{.*}}, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001470
1471TEST_UNINIT(unmatchedfp, unmatchedfp);
1472// CHECK-LABEL: @test_unmatchedfp_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001473// CHECK: %uninit = alloca %union.unmatchedfp, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001474// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001475// PATTERN-LABEL: @test_unmatchedfp_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001476// PATTERN-O0: call void @llvm.memcpy{{.*}} @__const.test_unmatchedfp_uninit.uninit
JF Bastien14daa202018-12-18 05:12:21 +00001477// ZERO-LABEL: @test_unmatchedfp_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001478// ZERO-O0: call void @llvm.memset{{.*}}, i8 0,
1479// ZERO-O1: store i64 0, {{.*}} align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001480
1481TEST_BRACES(unmatchedfp, unmatchedfp);
1482// CHECK-LABEL: @test_unmatchedfp_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001483// CHECK: %braces = alloca %union.unmatchedfp, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001484// CHECK-NEXT: bitcast
1485// CHECK-NEXT: call void @llvm.memcpy
1486// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1487
1488TEST_CUSTOM(unmatchedfp, unmatchedfp, { .d = 3.1415926535897932384626433 });
1489// CHECK-LABEL: @test_unmatchedfp_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001490// CHECK: %custom = alloca %union.unmatchedfp, align
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001491// CHECK-O0: bitcast
1492// CHECK-O0: call void @llvm.memcpy
1493// CHECK-O0: call void @{{.*}}used{{.*}}%custom)
1494// CHECK-O1: store i64 4614256656552045848, i64* %1, align 8
JF Bastienc70f65e2018-08-07 03:12:52 +00001495
1496TEST_UNINIT(emptyenum, emptyenum);
1497// CHECK-LABEL: @test_emptyenum_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001498// CHECK: %uninit = alloca i32, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001499// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001500// PATTERN-LABEL: @test_emptyenum_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001501// PATTERN: store i32 [[I32]], i32* %uninit, align 4
JF Bastien14daa202018-12-18 05:12:21 +00001502// ZERO-LABEL: @test_emptyenum_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001503// ZERO: store i32 0, i32* %uninit, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001504
1505TEST_BRACES(emptyenum, emptyenum);
1506// CHECK-LABEL: @test_emptyenum_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001507// CHECK: %braces = alloca i32, align [[ALIGN:[0-9]*]]
1508// CHECK-NEXT: store i32 0, i32* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001509// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1510
1511TEST_CUSTOM(emptyenum, emptyenum, { (emptyenum)42 });
1512// CHECK-LABEL: @test_emptyenum_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001513// CHECK: %custom = alloca i32, align [[ALIGN:[0-9]*]]
1514// CHECK-NEXT: store i32 42, i32* %custom, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001515// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1516
1517TEST_UNINIT(smallenum, smallenum);
1518// CHECK-LABEL: @test_smallenum_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001519// CHECK: %uninit = alloca i32, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001520// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001521// PATTERN-LABEL: @test_smallenum_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001522// PATTERN: store i32 [[I32]], i32* %uninit, align 4
JF Bastien14daa202018-12-18 05:12:21 +00001523// ZERO-LABEL: @test_smallenum_uninit()
Alexander Potapenkofa61ddd2019-03-01 09:00:41 +00001524// ZERO: store i32 0, i32* %uninit, align 4
JF Bastienc70f65e2018-08-07 03:12:52 +00001525
1526TEST_BRACES(smallenum, smallenum);
1527// CHECK-LABEL: @test_smallenum_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001528// CHECK: %braces = alloca i32, align [[ALIGN:[0-9]*]]
1529// CHECK-NEXT: store i32 0, i32* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001530// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1531
1532TEST_CUSTOM(smallenum, smallenum, { (smallenum)42 });
1533// CHECK-LABEL: @test_smallenum_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001534// CHECK: %custom = alloca i32, align [[ALIGN:[0-9]*]]
1535// CHECK-NEXT: store i32 42, i32* %custom, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001536// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1537
1538
1539TEST_UNINIT(intvec16, int __attribute__((vector_size(16))));
1540// CHECK-LABEL: @test_intvec16_uninit()
JF Bastiencc365c32018-08-07 22:43:44 +00001541// CHECK: %uninit = alloca <4 x i32>, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001542// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001543// PATTERN-LABEL: @test_intvec16_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001544// PATTERN: store <4 x i32> <i32 [[I32]], i32 [[I32]], i32 [[I32]], i32 [[I32]]>, <4 x i32>* %uninit, align 16
JF Bastien14daa202018-12-18 05:12:21 +00001545// ZERO-LABEL: @test_intvec16_uninit()
1546// ZERO: store <4 x i32> zeroinitializer, <4 x i32>* %uninit, align 16
JF Bastienc70f65e2018-08-07 03:12:52 +00001547
1548TEST_BRACES(intvec16, int __attribute__((vector_size(16))));
1549// CHECK-LABEL: @test_intvec16_braces()
JF Bastiencc365c32018-08-07 22:43:44 +00001550// CHECK: %braces = alloca <4 x i32>, align [[ALIGN:[0-9]*]]
1551// CHECK-NEXT: store <4 x i32> zeroinitializer, <4 x i32>* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001552// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1553
JF Bastien14daa202018-12-18 05:12:21 +00001554TEST_CUSTOM(intvec16, int __attribute__((vector_size(16))), { 0x44444444, 0x44444444, 0x44444444, 0x44444444 });
JF Bastienc70f65e2018-08-07 03:12:52 +00001555// CHECK-LABEL: @test_intvec16_custom()
JF Bastiencc365c32018-08-07 22:43:44 +00001556// CHECK: %custom = alloca <4 x i32>, align [[ALIGN:[0-9]*]]
1557// CHECK-NEXT: store <4 x i32> <i32 1145324612, i32 1145324612, i32 1145324612, i32 1145324612>, <4 x i32>* %custom, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001558// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1559
1560TEST_UNINIT(longlongvec32, long long __attribute__((vector_size(32))));
1561// CHECK-LABEL: @test_longlongvec32_uninit()
JF Bastien81377932018-08-07 04:44:13 +00001562// CHECK: %uninit = alloca <4 x i64>, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001563// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001564// PATTERN-LABEL: @test_longlongvec32_uninit()
Vitaly Buka669ad5f2019-07-12 01:36:11 +00001565// PATTERN: store <4 x i64> <i64 [[I64]], i64 [[I64]], i64 [[I64]], i64 [[I64]]>, <4 x i64>* %uninit, align 32
JF Bastien14daa202018-12-18 05:12:21 +00001566// ZERO-LABEL: @test_longlongvec32_uninit()
1567// ZERO: store <4 x i64> zeroinitializer, <4 x i64>* %uninit, align 32
JF Bastienc70f65e2018-08-07 03:12:52 +00001568
1569TEST_BRACES(longlongvec32, long long __attribute__((vector_size(32))));
1570// CHECK-LABEL: @test_longlongvec32_braces()
JF Bastien81377932018-08-07 04:44:13 +00001571// CHECK: %braces = alloca <4 x i64>, align [[ALIGN:[0-9]*]]
1572// CHECK-NEXT: store <4 x i64> zeroinitializer, <4 x i64>* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001573// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1574
1575TEST_CUSTOM(longlongvec32, long long __attribute__((vector_size(32))), { 0x3333333333333333, 0x3333333333333333, 0x3333333333333333, 0x3333333333333333 });
1576// CHECK-LABEL: @test_longlongvec32_custom()
JF Bastien81377932018-08-07 04:44:13 +00001577// CHECK: %custom = alloca <4 x i64>, align [[ALIGN:[0-9]*]]
1578// 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 +00001579// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1580
1581TEST_UNINIT(floatvec16, float __attribute__((vector_size(16))));
1582// CHECK-LABEL: @test_floatvec16_uninit()
JF Bastien81377932018-08-07 04:44:13 +00001583// CHECK: %uninit = alloca <4 x float>, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001584// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001585// PATTERN-LABEL: @test_floatvec16_uninit()
1586// PATTERN: store <4 x float> <float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000, float 0xFFFFFFFFE0000000>, <4 x float>* %uninit, align 16
1587// ZERO-LABEL: @test_floatvec16_uninit()
1588// ZERO: store <4 x float> zeroinitializer, <4 x float>* %uninit, align 16
JF Bastienc70f65e2018-08-07 03:12:52 +00001589
1590TEST_BRACES(floatvec16, float __attribute__((vector_size(16))));
1591// CHECK-LABEL: @test_floatvec16_braces()
JF Bastien81377932018-08-07 04:44:13 +00001592// CHECK: %braces = alloca <4 x float>, align [[ALIGN:[0-9]*]]
1593// CHECK-NEXT: store <4 x float> zeroinitializer, <4 x float>* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001594// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1595
1596TEST_CUSTOM(floatvec16, float __attribute__((vector_size(16))), { 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433 });
1597// CHECK-LABEL: @test_floatvec16_custom()
JF Bastien81377932018-08-07 04:44:13 +00001598// CHECK: %custom = alloca <4 x float>, align [[ALIGN:[0-9]*]]
1599// 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 +00001600// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1601
1602TEST_UNINIT(doublevec32, double __attribute__((vector_size(32))));
1603// CHECK-LABEL: @test_doublevec32_uninit()
JF Bastien81377932018-08-07 04:44:13 +00001604// CHECK: %uninit = alloca <4 x double>, align
JF Bastienc70f65e2018-08-07 03:12:52 +00001605// CHECK-NEXT: call void @{{.*}}used{{.*}}%uninit)
JF Bastien14daa202018-12-18 05:12:21 +00001606// PATTERN-LABEL: @test_doublevec32_uninit()
1607// PATTERN: store <4 x double> <double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF, double 0xFFFFFFFFFFFFFFFF>, <4 x double>* %uninit, align 32
1608// ZERO-LABEL: @test_doublevec32_uninit()
1609// ZERO: store <4 x double> zeroinitializer, <4 x double>* %uninit, align 32
JF Bastienc70f65e2018-08-07 03:12:52 +00001610
1611TEST_BRACES(doublevec32, double __attribute__((vector_size(32))));
1612// CHECK-LABEL: @test_doublevec32_braces()
JF Bastien81377932018-08-07 04:44:13 +00001613// CHECK: %braces = alloca <4 x double>, align [[ALIGN:[0-9]*]]
1614// CHECK-NEXT: store <4 x double> zeroinitializer, <4 x double>* %braces, align [[ALIGN]]
JF Bastienc70f65e2018-08-07 03:12:52 +00001615// CHECK-NEXT: call void @{{.*}}used{{.*}}%braces)
1616
1617TEST_CUSTOM(doublevec32, double __attribute__((vector_size(32))), { 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433, 3.1415926535897932384626433 });
1618// CHECK-LABEL: @test_doublevec32_custom()
JF Bastien81377932018-08-07 04:44:13 +00001619// CHECK: %custom = alloca <4 x double>, align [[ALIGN:[0-9]*]]
1620// 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 +00001621// CHECK-NEXT: call void @{{.*}}used{{.*}}%custom)
1622
1623
1624} // extern "C"