@@ -233,25 +233,23 @@ void init_expr(int a, int b, int c) {
233233
234234void cxx_default_init_with_struct_field () {
235235 struct Parent {
236- struct {
237- int a;
238- } child;
236+ int getA ();
237+ int a = getA();
239238 };
240239 Parent p = Parent{};
241240}
242241
243242// CIR: %[[P_ADDR:.*]] = cir.alloca !rec_Parent, !cir.ptr<!rec_Parent>, ["p", init]
244- // CIR: %[[P_ELEM_0_PTR:.*]] = cir.get_member %[[P_ADDR]][0] {name = "child"} : !cir.ptr<!rec_Parent> -> !cir.ptr<!rec_anon2E0>
245- // CIR: %[[CHILD_ELEM_0_PTR:.*]] = cir.get_member %[[P_ELEM_0_PTR]][0] {name = "a"} : !cir.ptr<!rec_anon2E0> -> !cir.ptr<!s32i>
246- // CIR: %[[CONST_0:.*]] = cir.const #cir.int<0> : !s32i
247- // CIR: cir.store{{.*}} %3, %[[CHILD_ELEM_0_PTR]] : !s32i, !cir.ptr<!s32i>
248-
249- // TODO(cir): zero-initialize the padding
243+ // CIR: %[[P_ELEM_0_PTR:.*]] = cir.get_member %[[P_ADDR]][0] {name = "a"} : !cir.ptr<!rec_Parent> -> !cir.ptr<!s32i>
244+ // CIR: %[[METHOD_CALL:.*]] = cir.call @_ZZ34cxx_default_init_with_struct_fieldvEN6Parent4getAEv(%[[P_ADDR]]) : (!cir.ptr<!rec_Parent>) -> !s32i
245+ // CIR: cir.store{{.*}} %[[METHOD_CALL]], %[[P_ELEM_0_PTR]] : !s32i, !cir.ptr<!s32i>
250246
251247// LLVM: %[[P_ADDR:.*]] = alloca %struct.Parent, i64 1, align 4
252248// LLVM: %[[P_ELEM_0_PTR:.*]] = getelementptr %struct.Parent, ptr %[[P_ADDR]], i32 0, i32 0
253- // LLVM: %[[CHILD_ELEM_0_PTR :.*]] = getelementptr %struct.anon.0, ptr %[[P_ELEM_0_PTR]], i32 0, i32 0
254- // LLVM: store i32 0 , ptr %[[CHILD_ELEM_0_PTR ]], align 4
249+ // LLVM: %[[METHOD_CALL :.*]] = call i32 @_ZZ34cxx_default_init_with_struct_fieldvEN6Parent4getAEv( ptr %[[P_ADDR]])
250+ // LLVM: store i32 %[[METHOD_CALL]] , ptr %[[P_ELEM_0_PTR ]], align 4
255251
256252// OGCG: %[[P_ADDR:.*]] = alloca %struct.Parent, align 4
257- // OGCG: call void @llvm.memset.p0.i64(ptr align 4 %[[P_ADDR]], i8 0, i64 4, i1 false)
253+ // OGCG: %[[P_ELEM_0_PTR:.*]] = getelementptr inbounds nuw %struct.Parent, ptr %[[P_ADDR]], i32 0, i32 0
254+ // OGCG: %[[METHOD_CALL:.*]] = call noundef i32 @_ZZ34cxx_default_init_with_struct_fieldvEN6Parent4getAEv(ptr {{.*}} %[[P_ADDR]])
255+ // OGCG: store i32 %[[METHOD_CALL]], ptr %[[P_ELEM_0_PTR]], align 4
0 commit comments