|
| 1 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -emit-cir -o %t-default.cir |
| 2 | +// RUN: FileCheck --input-file=%t-default.cir %s -check-prefix=CIR-DEFAULT |
| 3 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fno-common -emit-cir -o %t-no-common.cir |
| 4 | +// RUN: FileCheck --input-file=%t-no-common.cir %s -check-prefix=CIR-DEFAULT |
| 5 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fcommon -emit-cir -o %t-common.cir |
| 6 | +// RUN: FileCheck --input-file=%t-common.cir %s -check-prefix=CIR-COMMON |
| 7 | + |
| 8 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -emit-llvm -o %t-default-cir.ll |
| 9 | +// RUN: FileCheck --input-file=%t-default-cir.ll %s -check-prefix=LLVM-DEFAULT |
| 10 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fno-common -emit-llvm -o %t-no-common-cir.ll |
| 11 | +// RUN: FileCheck --input-file=%t-no-common-cir.ll %s -check-prefix=LLVM-DEFAULT |
| 12 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir %s -fcommon -emit-llvm -o %t-common-cir.ll |
| 13 | +// RUN: FileCheck --input-file=%t-common-cir.ll %s -check-prefix=LLVM-COMMON |
| 14 | + |
| 15 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o %t-default.ll |
| 16 | +// RUN: FileCheck --input-file=%t-default.ll %s -check-prefix=OGCG-DEFAULT |
| 17 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -fno-common -emit-llvm -o %t-no-common.ll |
| 18 | +// RUN: FileCheck --input-file=%t-no-common.ll %s -check-prefix=OGCG-DEFAULT |
| 19 | +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -fcommon -emit-llvm -o %t-common.ll |
| 20 | +// RUN: FileCheck --input-file=%t-common.ll %s -check-prefix=OGCG-COMMON |
| 21 | + |
| 22 | +const int a = 42; |
| 23 | +// CIR-DEFAULT: cir.global constant external @a = #cir.int<42> |
| 24 | +// LLVM-DEFAULT: @a = constant i32 42 |
| 25 | +// OGCG-DEFAULT: @a = constant i32 42 |
| 26 | + |
| 27 | +// CIR-COMMON: cir.global constant external @a |
| 28 | +// LLVM-COMMON: @a = constant i32 42 |
| 29 | +// OGCG-COMMON: @a = constant i32 42 |
| 30 | + |
| 31 | +const int b __attribute__((common)) = 42; |
| 32 | +// CIR-DEFAULT: cir.global constant external @b = #cir.int<42> |
| 33 | +// LLVM-DEFAULT: @b = constant i32 42 |
| 34 | +// OGCG-DEFAULT: @b = constant i32 42 |
| 35 | + |
| 36 | +// CIR-COMMON: cir.global constant external @b = #cir.int<42> |
| 37 | +// LLVM-COMMON: @b = constant i32 42 |
| 38 | +// OGCG-COMMON: @b = constant i32 42 |
| 39 | + |
| 40 | +const int c __attribute__((nocommon)) = 42; |
| 41 | +// CIR-DEFAULT: cir.global constant external @c = #cir.int<42> |
| 42 | +// LLVM-DEFAULT: @c = constant i32 42 |
| 43 | +// OGCG-DEFAULT: @c = constant i32 42 |
| 44 | + |
| 45 | +// CIR-COMMON: cir.global constant external @c = #cir.int<42> |
| 46 | +// LLVM-COMMON: @c = constant i32 42 |
| 47 | +// OGCG-COMMON: @c = constant i32 42 |
| 48 | + |
| 49 | +int d = 11; |
| 50 | +// CIR-DEFAULT: cir.global external @d = #cir.int<11> |
| 51 | +// LLVM-DEFAULT: @d = global i32 11 |
| 52 | +// OGCG-DEFAULT: @d = global i32 11 |
| 53 | + |
| 54 | +// CIR-COMMON: cir.global external @d = #cir.int<11> |
| 55 | +// LLVM-COMMON: @d = global i32 11 |
| 56 | +// OGCG-COMMON: @d = global i32 11 |
| 57 | + |
| 58 | +int e; |
| 59 | +// CIR-DEFAULT: cir.global external @e = #cir.int<0> |
| 60 | +// LLVM-DEFAULT: @e = global i32 0 |
| 61 | +// OGCG-DEFAULT: @e = global i32 0 |
| 62 | + |
| 63 | +// CIR-COMMON: cir.global common @e = #cir.int<0> |
| 64 | +// LLVM-COMMON: @e = common global i32 0 |
| 65 | +// OGCG-COMMON: @e = common global i32 0 |
| 66 | + |
| 67 | + |
| 68 | +int f __attribute__((common)); |
| 69 | +// CIR-DEFAULT: cir.global common @f = #cir.int<0> |
| 70 | +// LLVM-DEFAULT: @f = common global i32 0 |
| 71 | +// OGCG-DEFAULT: @f = common global i32 0 |
| 72 | + |
| 73 | +// CIR-COMMON: cir.global common @f |
| 74 | +// LLVM-COMMON: @f = common global i32 0 |
| 75 | +// OGCG-COMMON: @f = common global i32 0 |
| 76 | + |
| 77 | +int g __attribute__((nocommon)); |
| 78 | +// CIR-DEFAULT: cir.global external @g = #cir.int<0> |
| 79 | +// LLVM-DEFAULT: @g = global i32 |
| 80 | +// OGCG-DEFAULT: @g = global i32 0 |
| 81 | + |
| 82 | +// CIR-COMMON: cir.global external @g = #cir.int<0> |
| 83 | +// LLVM-COMMON: @g = global i32 0 |
| 84 | +// OGCG-COMMON: @g = global i32 0 |
| 85 | + |
| 86 | +const int h; |
| 87 | +// CIR-DEFAULT: cir.global constant external @h = #cir.int<0> |
| 88 | +// LLVM-DEFAULT: @h = constant i32 |
| 89 | +// OGCG-DEFAULT: @h = constant i32 0 |
| 90 | + |
| 91 | +// CIR-COMMON: cir.global common @h = #cir.int<0> |
| 92 | +// LLVM-COMMON: @h = common global i32 0 |
| 93 | +// OGCG-COMMON: @h = common global i32 0 |
| 94 | + |
| 95 | +typedef void* (*fn_t)(long a, long b, char *f, int c); |
| 96 | +fn_t ABC __attribute__ ((nocommon)); |
| 97 | +// CIR-DEFAULT: cir.global external @ABC = #cir.ptr<null> |
| 98 | +// LLVM-DEFAULT: @ABC = global ptr null |
| 99 | +// OGCG-DEFAULT: @ABC = global ptr null |
| 100 | + |
| 101 | +// CIR-COMMON: cir.global external @ABC = #cir.ptr<null> |
| 102 | +// LLVM-COMMON: @ABC = global ptr null |
| 103 | +// OGCG-COMMON: @ABC = global ptr null |
0 commit comments