@@ -183,3 +183,67 @@ void generic_selection() {
183
183
// OGCG: %[[C_ADDR:.*]] = alloca i32, align 4
184
184
// OGCG: %[[D_ADDR:.*]] = alloca %struct.CompleteS, align 4
185
185
// OGCG: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[D_ADDR]], ptr align 4 %[[A_ADDR]], i64 8, i1 false)
186
+
187
+ void atomic_init () {
188
+ _Atomic CompleteS a;
189
+ __c11_atomic_init (&a, {});
190
+ }
191
+
192
+ // CIR: cir.func{{.*}} @_Z11atomic_initv()
193
+ // CIR: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a"]
194
+ // CIR: %[[ELEM_0_PTR:.*]] = cir.get_member %[[A_ADDR]][0] {name = "a"} : !cir.ptr<!rec_CompleteS> -> !cir.ptr<!s32i>
195
+ // CIR: %[[CONST_0:.*]] = cir.const #cir.int<0> : !s32i
196
+ // CIR: cir.store{{.*}} %[[CONST_0]], %[[ELEM_0_PTR]] : !s32i, !cir.ptr<!s32i>
197
+ // CIR: %[[ELEM_1_PTR:.*]] = cir.get_member %[[A_ADDR]][1] {name = "b"} : !cir.ptr<!rec_CompleteS> -> !cir.ptr<!s8i>
198
+ // CIR: %[[CONST_0:.*]] = cir.const #cir.int<0> : !s8i
199
+ // CIR: cir.store{{.*}} %[[CONST_0]], %[[ELEM_1_PTR]] : !s8i, !cir.ptr<!s8i>
200
+
201
+ // LLVM: define{{.*}} void @_Z11atomic_initv()
202
+ // LLVM: %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 8
203
+ // LLVM: %[[ELEM_0_PTR:.*]] = getelementptr %struct.CompleteS, ptr %[[A_ADDR]], i32 0, i32 0
204
+ // LLVM: store i32 0, ptr %[[ELEM_0_PTR]], align 8
205
+ // LLVM: %[[ELEM_1_PTR:.*]] = getelementptr %struct.CompleteS, ptr %[[A_ADDR]], i32 0, i32 1
206
+ // LLVM: store i8 0, ptr %[[ELEM_1_PTR]], align 4
207
+
208
+ // OGCG: define{{.*}} void @_Z11atomic_initv()
209
+ // OGCG: %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 8
210
+ // OGCG: %[[ELEM_0_PTR:.*]] = getelementptr inbounds nuw %struct.CompleteS, ptr %[[A_ADDR]], i32 0, i32 0
211
+ // OGCG: store i32 0, ptr %[[ELEM_0_PTR]], align 8
212
+ // OGCG: %[[ELEM_1_PTR:.*]] = getelementptr inbounds nuw %struct.CompleteS, ptr %[[A_ADDR]], i32 0, i32 1
213
+ // OGCG: store i8 0, ptr %[[ELEM_1_PTR]], align 4
214
+
215
+ void unary_extension () {
216
+ CompleteS a = __extension__ CompleteS ();
217
+ }
218
+
219
+ // CIR: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a", init]
220
+ // CIR: %[[ZERO_INIT:.*]] = cir.const #cir.zero : !rec_CompleteS
221
+ // CIR: cir.store{{.*}} %[[ZERO_INIT]], %[[A_ADDR]] : !rec_CompleteS, !cir.ptr<!rec_CompleteS>
222
+
223
+ // LLVM: %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
224
+ // LLVM: store %struct.CompleteS zeroinitializer, ptr %[[A_ADDR]], align 4
225
+
226
+ // OGCG: %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
227
+ // OGCG: call void @llvm.memset.p0.i64(ptr align 4 %[[A_ADDR]], i8 0, i64 8, i1 false)
228
+
229
+ void bin_comma () {
230
+ CompleteS a = (CompleteS (), CompleteS ());
231
+ }
232
+
233
+ // CIR: cir.func{{.*}} @_Z9bin_commav()
234
+ // CIR: %[[A_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["a", init]
235
+ // CIR: %[[TMP_ADDR:.*]] = cir.alloca !rec_CompleteS, !cir.ptr<!rec_CompleteS>, ["agg.tmp0"]
236
+ // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !rec_CompleteS
237
+ // CIR: cir.store{{.*}} %[[ZERO]], %[[TMP_ADDR]] : !rec_CompleteS, !cir.ptr<!rec_CompleteS>
238
+ // CIR: %[[ZERO:.*]] = cir.const #cir.zero : !rec_CompleteS
239
+ // CIR: cir.store{{.*}} %[[ZERO]], %[[A_ADDR]] : !rec_CompleteS, !cir.ptr<!rec_CompleteS>
240
+
241
+ // LLVM: define{{.*}} void @_Z9bin_commav()
242
+ // LLVM: %[[A_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
243
+ // LLVM: %[[TMP_ADDR:.*]] = alloca %struct.CompleteS, i64 1, align 4
244
+ // LLVM: store %struct.CompleteS zeroinitializer, ptr %[[TMP_ADDR]], align 4
245
+ // LLVM: store %struct.CompleteS zeroinitializer, ptr %[[A_ADDR]], align 4
246
+
247
+ // OGCG: define{{.*}} void @_Z9bin_commav()
248
+ // OGCG: %[[A_ADDR:.*]] = alloca %struct.CompleteS, align 4
249
+ // OGCG: call void @llvm.memset.p0.i64(ptr align 4 %[[A_ADDR]], i8 0, i64 8, i1 false)
0 commit comments