Debian Codegraph @

clang/test/CIR/global-var-linkage.cpp

raw
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 int aaaa;
10 // CIR: cir.global external @aaaa
11 // LLVM: @aaaa = global i32 0
12 // OGCG: @aaaa = global i32 0
13
14 [[gnu::selectany]] int dddd;
15 // CIR: cir.global weak_odr comdat @dddd
16 // LLVM: @dddd = weak_odr global i32 0, comdat
17 // OGCG: @dddd = weak_odr global i32 0, comdat
18
19 static int bbbb;
20 // CIR: cir.global "private" internal dso_local @_ZL4bbbb
21 // LLVM: @_ZL4bbbb = internal global i32 0
22 // OGCG: @_ZL4bbbb = internal global i32 0
23
24 inline int cccc;
25 // CIR: cir.global linkonce_odr comdat @cccc
26 // LLVM: @cccc = linkonce_odr global i32 0, comdat
27 // OGCG: @cccc = linkonce_odr global i32 0, comdat
28
29 // Force the global variables to be emitted
30 void reference_vars() {
31 bbbb;
32 cccc;
33 }