|
2 | 2 | // RUN: FileCheck --input-file=%t.cir %s |
3 | 3 | // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t1.ll |
4 | 4 | // RUN: FileCheck --check-prefix=LLVM --input-file=%t1.ll %s |
| 5 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t1.ll |
| 6 | +// RUN: FileCheck --check-prefix=OGCG --input-file=%t1.ll %s |
| 7 | + |
| 8 | +template<typename T> |
| 9 | +struct implicitly_instantiated { |
| 10 | + static T member; |
| 11 | +}; |
| 12 | + |
| 13 | +template<typename T> |
| 14 | +T implicitly_instantiated<T>::member = 12345; |
| 15 | + |
| 16 | +int use_implicitly_instantiated() { |
| 17 | + return implicitly_instantiated<int>::member; |
| 18 | +} |
| 19 | + |
| 20 | +// CHECK-DAG: cir.global linkonce_odr comdat @_ZN23implicitly_instantiatedIiE6memberE = #cir.int<12345> : !s32i |
| 21 | +// LLVM-DAG: @_ZN23implicitly_instantiatedIiE6memberE = linkonce_odr global i32 12345, comdat |
| 22 | +// OGCG-DAG: @_ZN23implicitly_instantiatedIiE6memberE = linkonce_odr global i32 12345, comdat |
| 23 | + |
| 24 | +template<typename T> |
| 25 | +struct explicitly_instantiated { |
| 26 | + static T member; |
| 27 | +}; |
| 28 | + |
| 29 | +template<typename T> |
| 30 | +T explicitly_instantiated<T>::member = 54321; |
| 31 | + |
| 32 | +template int explicitly_instantiated<int>::member; |
| 33 | +// CHECK-DAG: cir.global weak_odr comdat @_ZN23explicitly_instantiatedIiE6memberE = #cir.int<54321> : !s32i |
| 34 | +// LLVM-DAG: @_ZN23explicitly_instantiatedIiE6memberE = weak_odr global i32 54321, comdat |
| 35 | +// OGCG-DAG: @_ZN23explicitly_instantiatedIiE6memberE = weak_odr global i32 54321, comdat |
5 | 36 |
|
6 | 37 | void func1(void) { |
7 | 38 | // Should lower default-initialized static vars. |
@@ -42,6 +73,8 @@ void func2(void) { |
42 | 73 |
|
43 | 74 | // LLVM-DAG: $_ZZ4testvE1c = comdat any |
44 | 75 | // LLVM-DAG: @_ZZ4testvE1c = linkonce_odr global i32 0, comdat, align 4 |
| 76 | +// OGCG-DAG: $_ZZ4testvE1c = comdat any |
| 77 | +// OGCG-DAG: @_ZZ4testvE1c = linkonce_odr global i32 0, comdat, align 4 |
45 | 78 |
|
46 | 79 | inline void test() { static int c; } |
47 | 80 | // CHECK-LABEL: @_Z4testv |
|
0 commit comments