| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++11 -fclangir -emit-cir %s -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR |
| 3 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++11 -fclangir -emit-llvm %s -o %t-cir.ll |
| 4 |
// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM |
| 5 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++11 -emit-llvm %s -o %t.ll |
| 6 |
// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG |
| 7 |
|
| 8 |
struct StructWithDefaultCtor { |
| 9 |
int n; |
| 10 |
}; |
| 11 |
|
| 12 |
StructWithDefaultCtor defCtor = StructWithDefaultCtor(); |
| 13 |
|
| 14 |
// CIR: cir.global {{.*}} @defCtor = #cir.zero : !rec_StructWithDefaultCtor |
| 15 |
// LLVM: @defCtor = global %struct.StructWithDefaultCtor zeroinitializer |
| 16 |
// OGCG: @defCtor = global %struct.StructWithDefaultCtor zeroinitializer |
| 17 |
|
| 18 |
struct StructWithCtorArg { |
| 19 |
double value; |
| 20 |
StructWithCtorArg(const double& x) : value(x) {} |
| 21 |
}; |
| 22 |
|
| 23 |
StructWithCtorArg withArg = 0.0; |
| 24 |
|
| 25 |
// CIR: cir.global {{.*}} @withArg = #cir.zero : !rec_StructWithCtorArg |
| 26 |
// LLVM: @withArg = global %struct.StructWithCtorArg zeroinitializer |
| 27 |
// OGCG: @withArg = global %struct.StructWithCtorArg zeroinitializer |
| 28 |
|
| 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.double |
| 33 |
// 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 double |
| 38 |
// 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 double |
| 43 |
// OGCG: store double 0.000000e+00, ptr %[[TMP0]] |
| 44 |
// OGCG: call void @_ZN17StructWithCtorArgC1ERKd(ptr {{.*}} @withArg, ptr {{.*}} %[[TMP0]]) |