45 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++11 -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++11 -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++11 -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG7 8struct StructWithDefaultCtor {9 int n;10};11 12StructWithDefaultCtor defCtor = StructWithDefaultCtor();13 14// CIR: cir.global {{.*}} @defCtor = #cir.zero : !rec_StructWithDefaultCtor15// LLVM: @defCtor = global %struct.StructWithDefaultCtor zeroinitializer16// OGCG: @defCtor = global %struct.StructWithDefaultCtor zeroinitializer17 18struct StructWithCtorArg {19 double value;20 StructWithCtorArg(const double& x) : value(x) {}21};22 23StructWithCtorArg withArg = 0.0;24 25// CIR: cir.global {{.*}} @withArg = #cir.zero : !rec_StructWithCtorArg26// LLVM: @withArg = global %struct.StructWithCtorArg zeroinitializer27// OGCG: @withArg = global %struct.StructWithCtorArg zeroinitializer28 29// CIR: cir.func {{.*}} @__cxx_global_var_init()30// CIR: %[[TMP0:.*]] = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["ref.tmp0"]31// CIR: %[[WITH_ARG:.*]] = cir.get_global @withArg : !cir.ptr<!rec_StructWithCtorArg>32// CIR: %[[ZERO:.*]] = cir.const #cir.fp<0.000000e+00> : !cir.double33// CIR: cir.store{{.*}} %[[ZERO]], %[[TMP0]] : !cir.double, !cir.ptr<!cir.double>34// CIR: cir.call @_ZN17StructWithCtorArgC1ERKd(%[[WITH_ARG]], %[[TMP0]]) : (!cir.ptr<!rec_StructWithCtorArg>, !cir.ptr<!cir.double>) -> ()35 36// LLVM: define {{.*}} void @__cxx_global_var_init()37// LLVM: %[[TMP0:.*]] = alloca double38// LLVM: store double 0.000000e+00, ptr %[[TMP0]]39// LLVM: call void @_ZN17StructWithCtorArgC1ERKd(ptr @withArg, ptr %[[TMP0]])40 41// OGCG: define {{.*}} void @__cxx_global_var_init()42// OGCG: %[[TMP0:.*]] = alloca double43// OGCG: store double 0.000000e+00, ptr %[[TMP0]]44// OGCG: call void @_ZN17StructWithCtorArgC1ERKd(ptr {{.*}} @withArg, ptr {{.*}} %[[TMP0]])45