34 lines · cpp
1// Linkage types of global variables2// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir3// RUN: FileCheck %s -check-prefix=CIR --input-file %t.cir4// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll5// RUN: FileCheck %s -check-prefix=LLVM --input-file %t-cir.ll6// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll7// RUN: FileCheck %s -check-prefix=OGCG --input-file %t.ll8 9int aaaa;10// CIR: cir.global external @aaaa11// LLVM: @aaaa = global i32 012// OGCG: @aaaa = global i32 013 14[[gnu::selectany]] int dddd;15// CIR: cir.global weak_odr comdat @dddd16// LLVM: @dddd = weak_odr global i32 0, comdat17// OGCG: @dddd = weak_odr global i32 0, comdat18 19static int bbbb;20// CIR: cir.global "private" internal dso_local @_ZL4bbbb21// LLVM: @_ZL4bbbb = internal global i32 022// OGCG: @_ZL4bbbb = internal global i32 023 24inline int cccc;25// CIR: cir.global linkonce_odr comdat @cccc26// LLVM: @cccc = linkonce_odr global i32 0, comdat27// OGCG: @cccc = linkonce_odr global i32 0, comdat28 29// Force the global variables to be emitted30void reference_vars() {31 bbbb;32 cccc;33}34