| 1 |
// Linkage types of global variables |
| 2 |
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir |
| 3 |
// RUN: FileCheck %s -check-prefix=CIR --input-file %t.cir |
| 4 |
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll |
| 5 |
// RUN: FileCheck %s -check-prefix=LLVM --input-file %t-cir.ll |
| 6 |
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll |
| 7 |
// RUN: FileCheck %s -check-prefix=OGCG --input-file %t.ll |
| 8 |
|
| 9 |
void a() {} |
| 10 |
|
| 11 |
// CIR: cir.func no_inline dso_local @_Z1av() |
| 12 |
// LLVM: define dso_local void @_Z1av() |
| 13 |
// OGCG: define dso_local void @_Z1av() |
| 14 |
|
| 15 |
extern void b(); |
| 16 |
// CIR: cir.func private @_Z1bv() |
| 17 |
// LLVM: declare void @_Z1bv() |
| 18 |
// OGCG: declare void @_Z1bv() |
| 19 |
|
| 20 |
static void c() {} |
| 21 |
// CIR: cir.func no_inline internal private dso_local @_ZL1cv() |
| 22 |
// LLVM: define internal void @_ZL1cv() |
| 23 |
// OGCG: define internal void @_ZL1cv() |
| 24 |
|
| 25 |
inline void d() {} |
| 26 |
// CIR: cir.func {{.*}} comdat linkonce_odr @_Z1dv() |
| 27 |
// LLVM: define linkonce_odr void @_Z1dv() |
| 28 |
// OGCG: define linkonce_odr void @_Z1dv(){{.*}} comdat |
| 29 |
|
| 30 |
namespace { |
| 31 |
void e() {} |
| 32 |
} |
| 33 |
|
| 34 |
// CIR: cir.func {{.*}} internal private dso_local @_ZN12_GLOBAL__N_11eEv() |
| 35 |
// LLVM: define internal void @_ZN12_GLOBAL__N_11eEv() |
| 36 |
// OGCG: define internal void @_ZN12_GLOBAL__N_11eEv() |
| 37 |
|
| 38 |
void f(); |
| 39 |
// CIR: cir.func private @_Z1fv() |
| 40 |
// LLVM: declare void @_Z1fv() |
| 41 |
// OGCG: declare void @_Z1fv() |
| 42 |
|
| 43 |
// Force the functions to be emitted |
| 44 |
void reference_funcs() { |
| 45 |
a(); |
| 46 |
b(); |
| 47 |
c(); |
| 48 |
d(); |
| 49 |
e(); |
| 50 |
f(); |
| 51 |
} |