104 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -emit-cir -o %t-default.cir2// RUN: FileCheck --input-file=%t-default.cir %s -check-prefix=CIR-DEFAULT3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fno-common -emit-cir -o %t-no-common.cir4// RUN: FileCheck --input-file=%t-no-common.cir %s -check-prefix=CIR-DEFAULT5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fcommon -emit-cir -o %t-common.cir6// RUN: FileCheck --input-file=%t-common.cir %s -check-prefix=CIR-COMMON7 8// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -emit-llvm -o %t-default-cir.ll9// RUN: FileCheck --input-file=%t-default-cir.ll %s -check-prefix=LLVM-DEFAULT10// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fno-common -emit-llvm -o %t-no-common-cir.ll11// RUN: FileCheck --input-file=%t-no-common-cir.ll %s -check-prefix=LLVM-DEFAULT12// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fcommon -emit-llvm -o %t-common-cir.ll13// RUN: FileCheck --input-file=%t-common-cir.ll %s -check-prefix=LLVM-COMMON14 15// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o %t-default.ll16// RUN: FileCheck --input-file=%t-default.ll %s -check-prefix=OGCG-DEFAULT17// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -fno-common -emit-llvm -o %t-no-common.ll18// RUN: FileCheck --input-file=%t-no-common.ll %s -check-prefix=OGCG-DEFAULT19// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -fcommon -emit-llvm -o %t-common.ll20// RUN: FileCheck --input-file=%t-common.ll %s -check-prefix=OGCG-COMMON21 22const int a = 42;23// CIR-DEFAULT: cir.global constant external @a = #cir.int<42>24// LLVM-DEFAULT: @a = constant i32 4225// OGCG-DEFAULT: @a = constant i32 4226 27// CIR-COMMON: cir.global constant external @a28// LLVM-COMMON: @a = constant i32 4229// OGCG-COMMON: @a = constant i32 4230 31const int b __attribute__((common)) = 42;32// CIR-DEFAULT: cir.global constant external @b = #cir.int<42>33// LLVM-DEFAULT: @b = constant i32 4234// OGCG-DEFAULT: @b = constant i32 4235 36// CIR-COMMON: cir.global constant external @b = #cir.int<42>37// LLVM-COMMON: @b = constant i32 4238// OGCG-COMMON: @b = constant i32 4239 40const int c __attribute__((nocommon)) = 42;41// CIR-DEFAULT: cir.global constant external @c = #cir.int<42>42// LLVM-DEFAULT: @c = constant i32 4243// OGCG-DEFAULT: @c = constant i32 4244 45// CIR-COMMON: cir.global constant external @c = #cir.int<42>46// LLVM-COMMON: @c = constant i32 4247// OGCG-COMMON: @c = constant i32 4248 49int d = 11;50// CIR-DEFAULT: cir.global external @d = #cir.int<11>51// LLVM-DEFAULT: @d = global i32 1152// OGCG-DEFAULT: @d = global i32 1153 54// CIR-COMMON: cir.global external @d = #cir.int<11>55// LLVM-COMMON: @d = global i32 1156// OGCG-COMMON: @d = global i32 1157 58int e;59// CIR-DEFAULT: cir.global external @e = #cir.int<0>60// LLVM-DEFAULT: @e = global i32 061// OGCG-DEFAULT: @e = global i32 062 63// CIR-COMMON: cir.global common @e = #cir.int<0>64// LLVM-COMMON: @e = common global i32 065// OGCG-COMMON: @e = common global i32 066 67 68int f __attribute__((common));69// CIR-DEFAULT: cir.global common @f = #cir.int<0>70// LLVM-DEFAULT: @f = common global i32 071// OGCG-DEFAULT: @f = common global i32 072 73// CIR-COMMON: cir.global common @f74// LLVM-COMMON: @f = common global i32 075// OGCG-COMMON: @f = common global i32 076 77int g __attribute__((nocommon));78// CIR-DEFAULT: cir.global external @g = #cir.int<0>79// LLVM-DEFAULT: @g = global i3280// OGCG-DEFAULT: @g = global i32 081 82// CIR-COMMON: cir.global external @g = #cir.int<0>83// LLVM-COMMON: @g = global i32 084// OGCG-COMMON: @g = global i32 085 86const int h;87// CIR-DEFAULT: cir.global constant external @h = #cir.int<0>88// LLVM-DEFAULT: @h = constant i3289// OGCG-DEFAULT: @h = constant i32 090 91// CIR-COMMON: cir.global common @h = #cir.int<0>92// LLVM-COMMON: @h = common global i32 093// OGCG-COMMON: @h = common global i32 094 95typedef void* (*fn_t)(long a, long b, char *f, int c);96fn_t ABC __attribute__ ((nocommon));97// CIR-DEFAULT: cir.global external @ABC = #cir.ptr<null>98// LLVM-DEFAULT: @ABC = global ptr null99// OGCG-DEFAULT: @ABC = global ptr null100 101// CIR-COMMON: cir.global external @ABC = #cir.ptr<null>102// LLVM-COMMON: @ABC = global ptr null103// OGCG-COMMON: @ABC = global ptr null104