Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / global-init.c
blob7f1d675b97c09e52660849a432d6b563ca28ab5d
1 // RUN: %clang_cc1 -emit-llvm -o - -triple i386-linux-gnu %s | FileCheck %s
3 // This checks that the global won't be marked as common.
4 // (It shouldn't because it's being initialized).
6 int a;
7 int a = 242;
8 // CHECK: @a ={{.*}} global i32 242
10 // This should get normal weak linkage.
11 int c __attribute__((weak))= 0;
12 // CHECK: @c = weak global i32 0
14 // Even though is marked const, it should get still get "weak"
15 // linkage, not "weak_odr" as the weak attribute makes it possible
16 // that there is a strong definition that changes the value linktime,
17 // so the value must not be considered constant.
18 // CHECK: @d = weak constant i32 0
19 const int d __attribute__((weak))= 0;
21 // However, "selectany" is similar to "weak", but isn't interposable
22 // by a strong definition, and should appear as weak_odr.
23 // CHECK: @e = weak_odr constant i32 17
24 const int e __attribute__((selectany)) = 17;
26 // PR6168 "too many undefs"
27 struct ManyFields {
28 int a;
29 int b;
30 int c;
31 char d;
32 int e;
33 int f;
36 // CHECK: global %struct.ManyFields { i32 1, i32 2, i32 0, i8 0, i32 0, i32 0 }
37 struct ManyFields FewInits = {1, 2};
40 // PR6766
41 // CHECK: @l ={{.*}} global %struct.K { [6 x i32] [i32 102, i32 111, i32 111, i32 0, i32 0, i32 0], i32 1 }
42 typedef __WCHAR_TYPE__ wchar_t;
43 struct K {
44 wchar_t L[6];
45 int M;
46 } l = { { L"foo" }, 1 };
49 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", [6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
50 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
52 unsigned long long x = -1000;
53 // CHECK: @x ={{.*}} global i64 -1000
54 unsigned long long uint_max = 4294967295u;
55 // CHECK: @uint_max ={{.*}} global i64 4294967295
58 // NOTE: tentative definitions are processed at the end of the translation unit.
60 // This shouldn't be emitted as common because it has an explicit section.
61 // CHECK: @b ={{.*}} global i32 0, section "foo"
62 int b __attribute__((section("foo")));