1 ; RUN: opt < %s -passes=globalopt -S | FileCheck %s
3 %ini = type { i32, ptr, ptr }
4 @llvm.global_ctors = appending global [16 x %ini] [
5 %ini { i32 65534, ptr @CTOR1, ptr null },
6 %ini { i32 65535, ptr @CTOR1, ptr null },
7 %ini { i32 65535, ptr @CTOR1, ptr null },
8 %ini { i32 65535, ptr @CTOR2, ptr null },
9 %ini { i32 65535, ptr @CTOR3, ptr null },
10 %ini { i32 65535, ptr @CTOR4, ptr null },
11 %ini { i32 65535, ptr @CTOR5, ptr null },
12 %ini { i32 65535, ptr @CTOR6, ptr null },
13 %ini { i32 65535, ptr @CTOR7, ptr null },
14 %ini { i32 65535, ptr @CTOR8, ptr null },
15 %ini { i32 65535, ptr @CTOR9, ptr null },
16 %ini { i32 65535, ptr @CTOR14,ptr null },
17 %ini { i32 65536, ptr @CTOR10_EXTERNAL, ptr null },
18 %ini { i32 65536, ptr @CTOR11, ptr null },
19 %ini { i32 65537, ptr @CTOR12, ptr null },
20 %ini { i32 2147483647, ptr null, ptr null }
23 @G = global i32 0 ; <ptr> [#uses=1]
24 @G2 = global i32 0 ; <ptr> [#uses=1]
25 @G3 = global i32 -123 ; <ptr> [#uses=2]
26 @X = global { i32, [2 x i32] } { i32 0, [2 x i32] [ i32 17, i32 21 ] } ; <ptr> [#uses=2]
27 @Y = global i32 -1 ; <ptr> [#uses=2]
28 @Z = global i32 123 ; <ptr> [#uses=1]
29 @D = global double 0.000000e+00 ; <ptr> [#uses=1]
30 @CTORGV = internal global i1 false ; <ptr> [#uses=2]
31 @GA = global i32 0 ; <ptr> [#uses=1]
32 @GA14 = global i32 0 ; <ptr> [#uses=1]
34 define internal void @CTOR1() {
38 define internal void @CTOR2() {
39 %A = add i32 1, 23 ; <i32> [#uses=1]
41 store i1 true, ptr @CTORGV
45 define internal void @CTOR3() {
46 %X = or i1 true, false ; <i1> [#uses=1]
50 br i1 %X, label %S, label %T
60 define internal void @CTOR4() {
61 %X = load i32, ptr @G3 ; <i32> [#uses=1]
62 %Y = add i32 %X, 123 ; <i32> [#uses=1]
67 define internal void @CTOR5() {
68 %X.2p = getelementptr inbounds { i32, [2 x i32] }, ptr @X, i32 0, i32 1, i32 0 ; <ptr> [#uses=2]
69 %X.2 = load i32, ptr %X.2p ; <i32> [#uses=1]
70 %X.1p = getelementptr inbounds { i32, [2 x i32] }, ptr @X, i32 0, i32 0 ; <ptr> [#uses=1]
71 store i32 %X.2, ptr %X.1p
72 store i32 42, ptr %X.2p
76 define internal void @CTOR6() {
77 %A = alloca i32 ; <ptr> [#uses=2]
78 %y = load i32, ptr @Y ; <i32> [#uses=1]
80 %Av = load i32, ptr %A ; <i32> [#uses=1]
81 %Av1 = add i32 %Av, 1 ; <i32> [#uses=1]
82 store i32 %Av1, ptr @Y
86 define internal void @CTOR7() {
87 call void @setto( ptr @Z, i32 0 )
91 define void @setto(ptr %P, i32 %V) {
96 declare double @cos(double)
98 define internal void @CTOR8() {
99 %X = call double @cos( double 0.000000e+00 ) ; <double> [#uses=1]
100 store double %X, ptr @D
104 define i1 @accessor() {
105 %V = load i1, ptr @CTORGV ; <i1> [#uses=1]
109 %struct.A = type { i32 }
110 %struct.B = type { ptr, ptr, [4 x i8] }
111 @GV1 = global %struct.B zeroinitializer, align 8
112 @GV2 = constant [3 x ptr] [ptr inttoptr (i64 16 to ptr), ptr null, ptr null]
114 define internal void @CTOR9() {
116 %0 = getelementptr inbounds i8, ptr @GV1, i64 16
117 store ptr getelementptr inbounds ([3 x ptr], ptr @GV2, i64 1, i64 0), ptr @GV1
121 ; CHECK: CTOR10_EXTERNAL
122 declare external void @CTOR10_EXTERNAL();
125 define internal void @CTOR11() {
130 define internal void @CTOR12() {
135 define internal void @CTOR13() {
136 store atomic i32 123, ptr @GA seq_cst, align 4
141 define internal void @CTOR14() {
142 %X = load atomic i32, ptr @GA14 seq_cst, align 4
144 store i32 %Y, ptr @GA14