@@ -152,3 +152,31 @@ void test_new_with_ctor() {
152
152
// OGCG: call{{.*}} void @_ZN2S2C1Eii(ptr {{.*}} %[[NEW_S2_2]], i32 noundef 1, i32 noundef 2)
153
153
// OGCG: store ptr %[[NEW_S2_2]], ptr %[[PS2_2_ADDR]], align 8
154
154
// OGCG: ret void
155
+
156
+ void test_new_with_complex_type () {
157
+ _Complex float *a = new _Complex float {1 .0f , 2 .0f };
158
+ }
159
+
160
+ // CHECK: cir.func{{.*}} @_Z26test_new_with_complex_typev
161
+ // CHECK: %0 = cir.alloca !cir.ptr<!cir.complex<!cir.float>>, !cir.ptr<!cir.ptr<!cir.complex<!cir.float>>>, ["a", init]
162
+ // CHECK: %1 = cir.const #cir.int<8> : !u64i
163
+ // CHECK: %2 = cir.call @_Znwm(%1) : (!u64i) -> !cir.ptr<!void>
164
+ // CHECK: %3 = cir.cast(bitcast, %2 : !cir.ptr<!void>), !cir.ptr<!cir.complex<!cir.float>>
165
+ // CHECK: %4 = cir.const #cir.const_complex<#cir.fp<1.000000e+00> : !cir.float, #cir.fp<2.000000e+00> : !cir.float> : !cir.complex<!cir.float>
166
+ // CHECK: cir.store align(8) %4, %3 : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>
167
+ // CHECK: cir.store align(8) %3, %0 : !cir.ptr<!cir.complex<!cir.float>>, !cir.ptr<!cir.ptr<!cir.complex<!cir.float>>>
168
+
169
+ // LLVM: define{{.*}} void @_Z26test_new_with_complex_typev
170
+ // LLVM: %[[A_ADDR:.*]] = alloca ptr, i64 1, align 8
171
+ // LLVM: %[[NEW_COMPLEX:.*]] = call ptr @_Znwm(i64 8)
172
+ // LLVM: store { float, float } { float 1.000000e+00, float 2.000000e+00 }, ptr %[[NEW_COMPLEX]], align 8
173
+ // LLVM: store ptr %[[NEW_COMPLEX]], ptr %[[A_ADDR]], align 8
174
+
175
+ // OGCG: define{{.*}} void @_Z26test_new_with_complex_typev
176
+ // OGCG: %[[A_ADDR:.*]] = alloca ptr, align 8
177
+ // OGCG: %[[NEW_COMPLEX:.*]] = call noalias noundef nonnull ptr @_Znwm(i64 noundef 8)
178
+ // OGCG: %[[COMPLEX_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[NEW_COMPLEX]], i32 0, i32 0
179
+ // OGCG: %[[COMPLEX_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[NEW_COMPLEX]], i32 0, i32 1
180
+ // OGCG: store float 1.000000e+00, ptr %[[COMPLEX_REAL_PTR]], align 8
181
+ // OGCG: store float 2.000000e+00, ptr %[[COMPLEX_IMAG_PTR]], align 4
182
+ // OGCG: store ptr %[[NEW_COMPLEX]], ptr %[[A_ADDR]], align 8
0 commit comments