1 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
14 // CHECK: _Z15test_value_initv
15 void test_value_init() {
16 // This value initialization requires zero initialization of the 'B'
17 // subobject followed by a call to its constructor.
20 // CHECK: store i32 17
21 // CHECK: call void @llvm.memset.p0i8.i64
22 // CHECK: call void @_ZN1BC1Ev
24 // CHECK: call void @_ZN1CD1Ev
27 enum enum_type { negative_number = -1, magic_number = 42 };
34 enum_holder() : m_enum(magic_number) { }
37 struct enum_holder_and_int
43 // CHECK: _Z24test_enum_holder_and_intv()
44 void test_enum_holder_and_int() {
46 // CHECK-NEXT: bitcast
47 // CHECK-NEXT: call void @llvm.memset
48 // CHECK-NEXT: call void @_ZN19enum_holder_and_intC1Ev
49 enum_holder_and_int();
50 // CHECK-NEXT: ret void
53 // PR7834: don't crash.
59 A &operator=(const A &);
77 // CHECK-LABEL: define i32 @_ZN6ptrmem4testEPNS_1SE
79 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64
80 // CHECK: getelementptr
100 struct Test3 : public Test { };
102 // CHECK-LABEL: define void @_ZN6PR98011fEv
104 // CHECK-NOT: call void @llvm.memset.p0i8.i64
105 // CHECK: call void @_ZN6PR98014TestC1Ei
106 // CHECK-NOT: call void @llvm.memset.p0i8.i64
107 // CHECK: call void @_ZN6PR98014TestC1Ev
108 Test partial[3] = { 1 };
110 // CHECK-NOT: call void @llvm.memset.p0i8.i64
111 // CHECK: call void @_ZN6PR98014TestC1Ev
112 // CHECK-NOT: call void @_ZN6PR98014TestC1Ev
115 // CHECK: call void @llvm.memset.p0i8.i64
116 // CHECK-NOT: call void @llvm.memset.p0i8.i64
117 // CHECK: call void @_ZN6PR98015Test2C1Ev
118 // CHECK-NOT: call void @_ZN6PR98015Test2C1Ev
119 Test2 empty2[3] = {};
121 // CHECK: call void @llvm.memset.p0i8.i64
122 // CHECK-NOT: call void @llvm.memset.p0i8.i64
123 // CHECK: call void @_ZN6PR98015Test3C1Ev
124 // CHECK-NOT: call void @llvm.memset.p0i8.i64
125 // CHECK-NOT: call void @_ZN6PR98015Test3C1Ev
126 Test3 empty3[3] = {};
134 // CHECK-LABEL: define i32 @_ZN8zeroinit4testEv()
136 // CHECK: call void @llvm.memset.p0i8.i64
151 // CHECK-LABEL: define void @_ZN8zeroinit9testX0_X1Ev
153 // CHECK: call void @llvm.memset.p0i8.i64
154 // CHECK-NEXT: call void @_ZN8zeroinit2X1C1Ev
155 // CHECK-NEXT: call void @_ZN8zeroinit2X11fEv
166 struct X3 : X2<int> {
172 // CHECK-LABEL: define void @_ZN8zeroinit9testX0_X3Ev
174 // CHECK-NOT: call void @llvm.memset
175 // CHECK: call void @_ZN8zeroinit2X3IiEC1Ev
176 // CHECK: call void @_ZN8zeroinit2X2IiE1fEv
177 // CHECK-NEXT: ret void
181 // More checks at EOF
197 // rdar://problem/9355931
199 struct A { A(); A(int); };
202 A arr[10][20] = { 5 };
204 // CHECK-LABEL: define void @_ZN5test64testEv()
205 // CHECK: [[ARR:%.*]] = alloca [10 x [20 x [[A:%.*]]]],
207 // CHECK-NEXT: [[INNER:%.*]] = getelementptr inbounds [10 x [20 x [[A]]]]* [[ARR]], i64 0, i64 0
208 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [20 x [[A]]]* [[INNER]], i64 0, i64 0
209 // CHECK-NEXT: call void @_ZN5test61AC1Ei([[A]]* [[T0]], i32 5)
210 // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [[A]]* [[T0]], i64 1
211 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[T0]], i64 20
212 // CHECK-NEXT: br label
213 // CHECK: [[CUR:%.*]] = phi [[A]]* [ [[BEGIN]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
214 // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[CUR]])
215 // CHECK-NEXT: [[NEXT]] = getelementptr inbounds [[A]]* [[CUR]], i64 1
216 // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[NEXT]], [[END]]
219 // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [20 x [[A]]]* [[INNER]], i64 1
220 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [20 x [[A]]]* [[INNER]], i64 10
221 // CHECK-NEXT: br label
222 // CHECK: [[CUR:%.*]] = phi [20 x [[A]]]* [ [[BEGIN]], {{%.*}} ], [ [[NEXT:%.*]], {{%.*}} ]
225 // CHECK-NEXT: [[IBEGIN:%.*]] = getelementptr inbounds [20 x [[A]]]* [[CUR]], i32 0, i32 0
226 // CHECK-NEXT: [[IEND:%.*]] = getelementptr inbounds [[A]]* [[IBEGIN]], i64 20
227 // CHECK-NEXT: br label
228 // CHECK: [[ICUR:%.*]] = phi [[A]]* [ [[IBEGIN]], {{%.*}} ], [ [[INEXT:%.*]], {{%.*}} ]
229 // CHECK-NEXT: call void @_ZN5test61AC1Ev([[A]]* [[ICUR]])
230 // CHECK-NEXT: [[INEXT:%.*]] = getelementptr inbounds [[A]]* [[ICUR]], i64 1
231 // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[INEXT]], [[IEND]]
232 // CHECK-NEXT: br i1 [[T0]],
234 // CHECK: [[NEXT]] = getelementptr inbounds [20 x [[A]]]* [[CUR]], i64 1
235 // CHECK-NEXT: [[T0:%.*]] = icmp eq [20 x [[A]]]* [[NEXT]], [[END]]
236 // CHECK-NEXT: br i1 [[T0]]
241 // Make sure C::C doesn't overwrite parts of A while it is zero-initializing B
242 struct A { int a; A(); A(int); };
243 struct B : virtual A { int b; };
244 struct C : B { C(); };
245 C::C() : A(3), B() {}
246 // CHECK-LABEL: define void @_ZN7PR111241CC1Ev
247 // CHECK: call void @llvm.memset.p0i8.i64(i8* {{.*}}, i8 0, i64 12, i32 8, i1 false)
248 // CHECK-NEXT: call void @_ZN7PR111241BC2Ev
249 // Make sure C::C doesn't overwrite parts of A while it is zero-initializing B
251 struct B2 : virtual A { int B::*b; };
252 struct C2 : B2 { C2(); };
253 C2::C2() : A(3), B2() {}
254 // CHECK-LABEL: define void @_ZN7PR111242C2C1Ev
255 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %{{.*}}, i8* {{.*}}, i64 16, i32 8, i1 false)
256 // CHECK-NEXT: call void @_ZN7PR111242B2C2Ev
259 // Ensure we produce an i1 here, and don't assert.
260 // CHECK-LABEL: define void @_Z9r170806_bv(
261 // CHECK: call void @_Z9r170806_ab(i1 zeroext false)
262 void r170806_a(bool b = bool());
263 void r170806_b() { r170806_a(); }
265 // CHECK-LABEL: define linkonce_odr void @_ZN8zeroinit2X3IiEC2Ev(%"struct.zeroinit::X3"* %this) unnamed_addr
266 // CHECK: call void @llvm.memset.p0i8.i64
267 // CHECK-NEXT: call void @_ZN8zeroinit2X2IiEC2Ev
268 // CHECK-NEXT: ret void