@@ -1429,3 +1429,42 @@ void imag_on_scalar_bool() {
14291429//  OGCG: %[[A_ADDR:.*]] = alloca i8, align 1
14301430//  OGCG: %[[B_ADDR:.*]] = alloca i8, align 1
14311431//  OGCG: store i8 0, ptr %[[B_ADDR]], align 1
1432+ 
1433+ void  function_with_complex_default_arg (
1434+     float  _Complex  a = __builtin_complex(1 .0f , 2 .2f )) {}
1435+ 
1436+ //  CIR: %[[ARG_0_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["a", init]
1437+ //  CIR: cir.store %{{.*}}, %[[ARG_0_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>
1438+ 
1439+ //  TODO(CIR): the difference between the CIR LLVM and OGCG is because the lack of calling convention lowering,
1440+ 
1441+ //  LLVM: %[[ARG_0_ADDR:.*]] = alloca { float, float }, i64 1, align 4
1442+ //  LLVM: store { float, float } %{{.*}}, ptr %[[ARG_0_ADDR]], align 4
1443+ 
1444+ //  OGCG: %[[ARG_0_ADDR:.*]] = alloca { float, float }, align 4
1445+ //  OGCG: store <2 x float> %{{.*}}, ptr %[[ARG_0_ADDR]], align 4
1446+ 
1447+ void  calling_function_with_default_arg () {
1448+   function_with_complex_default_arg ();
1449+ }
1450+ 
1451+ //  CIR: %[[DEFAULT_ARG_ADDR:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["coerce"]
1452+ //  CIR: %[[DEFAULT_ARG_VAL:.*]] = cir.const #cir.const_complex<#cir.fp<1.000000e+00> : !cir.float, #cir.fp<2.200000e+00> : !cir.float> : !cir.complex<!cir.float>
1453+ //  CIR: cir.store{{.*}} %[[DEFAULT_ARG_VAL]], %[[DEFAULT_ARG_ADDR]] : !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>
1454+ //  CIR: %[[TMP_DEFAULT_ARG:.*]] = cir.load{{.*}} %[[DEFAULT_ARG_ADDR]] : !cir.ptr<!cir.complex<!cir.float>>, !cir.complex<!cir.float>
1455+ //  CIR: cir.call @_Z33function_with_complex_default_argCf(%[[TMP_DEFAULT_ARG]]) : (!cir.complex<!cir.float>) -> ()
1456+ 
1457+ //  TODO(CIR): the difference between the CIR LLVM and OGCG is because the lack of calling convention lowering,
1458+ 
1459+ //  LLVM: %[[DEFAULT_ARG_ADDR:.*]] = alloca { float, float }, i64 1, align 4
1460+ //  LLVM: store { float, float } { float 1.000000e+00, float 0x40019999A0000000 }, ptr %[[DEFAULT_ARG_ADDR]], align 4
1461+ //  LLVM: %[[TMP_DEFAULT_ARG:.*]] = load { float, float }, ptr %[[DEFAULT_ARG_ADDR]], align 4
1462+ //  LLVM: call void @_Z33function_with_complex_default_argCf({ float, float } %[[TMP_DEFAULT_ARG]])
1463+ 
1464+ //  OGCG: %[[DEFAULT_ARG_ADDR:.*]] = alloca { float, float }, align 4
1465+ //  OGCG: %[[DEFAULT_ARG_REAL_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[DEFAULT_ARG_ADDR]], i32 0, i32 0
1466+ //  OGCG: %[[DEFAULT_ARG_IMAG_PTR:.*]] = getelementptr inbounds nuw { float, float }, ptr %[[DEFAULT_ARG_ADDR]], i32 0, i32 1
1467+ //  OGCG: store float 1.000000e+00, ptr %[[DEFAULT_ARG_REAL_PTR]], align 4
1468+ //  OGCG: store float 0x40019999A0000000, ptr %[[DEFAULT_ARG_IMAG_PTR]], align 4
1469+ //  OGCG: %[[TMP_DEFAULT_ARG:.*]] = load <2 x float>, ptr %[[DEFAULT_ARG_ADDR]], align 4
1470+ //  OGCG: call void @_Z33function_with_complex_default_argCf(<2 x float> {{.*}} %[[TMP_DEFAULT_ARG]])
0 commit comments