aboutsummaryrefslogtreecommitdiff
path: root/clang/test/CIR/func-linkage.cpp
blob: d43f7ed273063559a8043e119b6c5039dc96f373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Linkage types of global variables
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck %s -check-prefix=CIR --input-file %t.cir
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
// RUN: FileCheck %s -check-prefix=LLVM --input-file %t-cir.ll
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
// RUN: FileCheck %s -check-prefix=OGCG --input-file %t.ll

void a() {}

// CIR: cir.func dso_local @_Z1av()
// LLVM: define dso_local void @_Z1av()
// OGCG: define dso_local void @_Z1av()

extern void b();
// CIR: cir.func private @_Z1bv()
// LLVM: declare void @_Z1bv()
// OGCG: declare void @_Z1bv()

static void c() {}
// CIR: cir.func internal private dso_local @_ZL1cv()
// LLVM: define internal void @_ZL1cv()
// OGCG: define internal void @_ZL1cv()

inline void d() {}
// CIR: cir.func comdat linkonce_odr @_Z1dv()
// LLVM: define linkonce_odr void @_Z1dv()
// OGCG: define linkonce_odr void @_Z1dv(){{.*}} comdat

namespace {
  void e() {}
}

// CIR: cir.func internal private dso_local @_ZN12_GLOBAL__N_11eEv()
// LLVM: define internal void @_ZN12_GLOBAL__N_11eEv()
// OGCG: define internal void @_ZN12_GLOBAL__N_11eEv()

void f();
// CIR: cir.func private @_Z1fv()
// LLVM: declare void @_Z1fv()
// OGCG: declare void @_Z1fv()

// Force the functions to be emitted
void reference_funcs() {
    a();
    b();
    c();
    d();
    e();
    f();
}