1 ; RUN: opt < %s -globalopt -S | FileCheck %s
3 %ini = type { i32, void()*, i8* }
4 @llvm.global_ctors = appending global [11 x %ini] [
5 %ini { i32 65535, void ()* @CTOR1, i8* null },
6 %ini { i32 65535, void ()* @CTOR1, i8* null },
7 %ini { i32 65535, void ()* @CTOR2, i8* null },
8 %ini { i32 65535, void ()* @CTOR3, i8* null },
9 %ini { i32 65535, void ()* @CTOR4, i8* null },
10 %ini { i32 65535, void ()* @CTOR5, i8* null },
11 %ini { i32 65535, void ()* @CTOR6, i8* null },
12 %ini { i32 65535, void ()* @CTOR7, i8* null },
13 %ini { i32 65535, void ()* @CTOR8, i8* null },
14 %ini { i32 65535, void ()* @CTOR9, i8* null },
15 %ini { i32 2147483647, void ()* null, i8* null }
18 @G = global i32 0 ; <i32*> [#uses=1]
19 @G2 = global i32 0 ; <i32*> [#uses=1]
20 @G3 = global i32 -123 ; <i32*> [#uses=2]
21 @X = global { i32, [2 x i32] } { i32 0, [2 x i32] [ i32 17, i32 21 ] } ; <{ i32, [2 x i32] }*> [#uses=2]
22 @Y = global i32 -1 ; <i32*> [#uses=2]
23 @Z = global i32 123 ; <i32*> [#uses=1]
24 @D = global double 0.000000e+00 ; <double*> [#uses=1]
25 @CTORGV = internal global i1 false ; <i1*> [#uses=2]
27 define internal void @CTOR1() {
31 define internal void @CTOR2() {
32 %A = add i32 1, 23 ; <i32> [#uses=1]
34 store i1 true, i1* @CTORGV
38 define internal void @CTOR3() {
39 %X = or i1 true, false ; <i1> [#uses=1]
43 br i1 %X, label %S, label %T
46 store i32 24, i32* @G2
53 define internal void @CTOR4() {
54 %X = load i32, i32* @G3 ; <i32> [#uses=1]
55 %Y = add i32 %X, 123 ; <i32> [#uses=1]
56 store i32 %Y, i32* @G3
60 define internal void @CTOR5() {
61 %X.2p = getelementptr inbounds { i32, [2 x i32] }, { i32, [2 x i32] }* @X, i32 0, i32 1, i32 0 ; <i32*> [#uses=2]
62 %X.2 = load i32, i32* %X.2p ; <i32> [#uses=1]
63 %X.1p = getelementptr inbounds { i32, [2 x i32] }, { i32, [2 x i32] }* @X, i32 0, i32 0 ; <i32*> [#uses=1]
64 store i32 %X.2, i32* %X.1p
65 store i32 42, i32* %X.2p
69 define internal void @CTOR6() {
70 %A = alloca i32 ; <i32*> [#uses=2]
71 %y = load i32, i32* @Y ; <i32> [#uses=1]
73 %Av = load i32, i32* %A ; <i32> [#uses=1]
74 %Av1 = add i32 %Av, 1 ; <i32> [#uses=1]
75 store i32 %Av1, i32* @Y
79 define internal void @CTOR7() {
80 call void @setto( i32* @Z, i32 0 )
84 define void @setto(i32* %P, i32 %V) {
89 declare double @cos(double)
91 define internal void @CTOR8() {
92 %X = call double @cos( double 0.000000e+00 ) ; <double> [#uses=1]
93 store double %X, double* @D
97 define i1 @accessor() {
98 %V = load i1, i1* @CTORGV ; <i1> [#uses=1]
102 %struct.A = type { i32 }
103 %struct.B = type { i32 (...)**, i8*, [4 x i8] }
104 @GV1 = global %struct.B zeroinitializer, align 8
105 @GV2 = constant [3 x i8*] [i8* inttoptr (i64 16 to i8*), i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64 }* null to i8*)]
107 define internal void @CTOR9() {
109 %0 = bitcast %struct.B* @GV1 to i8*
110 %1 = getelementptr inbounds i8, i8* %0, i64 16
111 %2 = bitcast i8* %1 to %struct.A*
112 %3 = bitcast %struct.B* @GV1 to i8***
113 store i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @GV2, i64 1, i64 0), i8*** %3