1; RUN: opt < %s -globalopt -S | not grep CTOR 2@llvm.global_ctors = appending global [11 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @CTOR1 }, { i32, void ()* } { i32 65535, void ()* @CTOR1 }, { i32, void ()* } { i32 65535, void ()* @CTOR2 }, { i32, void ()* } { i32 65535, void ()* @CTOR3 }, { i32, void ()* } { i32 65535, void ()* @CTOR4 }, { i32, void ()* } { i32 65535, void ()* @CTOR5 }, { i32, void ()* } { i32 65535, void ()* @CTOR6 }, { i32, void ()* } { i32 65535, void ()* @CTOR7 }, { i32, void ()* } { i32 65535, void ()* @CTOR8 }, { i32, void ()* } { i32 65535, void ()* @CTOR9 }, { i32, void ()* } { i32 2147483647, void ()* null } ] ; <[10 x { i32, void ()* }]*> [#uses=0] 3@G = global i32 0 ; <i32*> [#uses=1] 4@G2 = global i32 0 ; <i32*> [#uses=1] 5@G3 = global i32 -123 ; <i32*> [#uses=2] 6@X = global { i32, [2 x i32] } { i32 0, [2 x i32] [ i32 17, i32 21 ] } ; <{ i32, [2 x i32] }*> [#uses=2] 7@Y = global i32 -1 ; <i32*> [#uses=2] 8@Z = global i32 123 ; <i32*> [#uses=1] 9@D = global double 0.000000e+00 ; <double*> [#uses=1] 10@CTORGV = internal global i1 false ; <i1*> [#uses=2] 11 12define internal void @CTOR1() { 13 ret void 14} 15 16define internal void @CTOR2() { 17 %A = add i32 1, 23 ; <i32> [#uses=1] 18 store i32 %A, i32* @G 19 store i1 true, i1* @CTORGV 20 ret void 21} 22 23define internal void @CTOR3() { 24 %X = or i1 true, false ; <i1> [#uses=1] 25 br label %Cont 26 27Cont: ; preds = %0 28 br i1 %X, label %S, label %T 29 30S: ; preds = %Cont 31 store i32 24, i32* @G2 32 ret void 33 34T: ; preds = %Cont 35 ret void 36} 37 38define internal void @CTOR4() { 39 %X = load i32* @G3 ; <i32> [#uses=1] 40 %Y = add i32 %X, 123 ; <i32> [#uses=1] 41 store i32 %Y, i32* @G3 42 ret void 43} 44 45define internal void @CTOR5() { 46 %X.2p = getelementptr inbounds { i32, [2 x i32] }* @X, i32 0, i32 1, i32 0 ; <i32*> [#uses=2] 47 %X.2 = load i32* %X.2p ; <i32> [#uses=1] 48 %X.1p = getelementptr inbounds { i32, [2 x i32] }* @X, i32 0, i32 0 ; <i32*> [#uses=1] 49 store i32 %X.2, i32* %X.1p 50 store i32 42, i32* %X.2p 51 ret void 52} 53 54define internal void @CTOR6() { 55 %A = alloca i32 ; <i32*> [#uses=2] 56 %y = load i32* @Y ; <i32> [#uses=1] 57 store i32 %y, i32* %A 58 %Av = load i32* %A ; <i32> [#uses=1] 59 %Av1 = add i32 %Av, 1 ; <i32> [#uses=1] 60 store i32 %Av1, i32* @Y 61 ret void 62} 63 64define internal void @CTOR7() { 65 call void @setto( i32* @Z, i32 0 ) 66 ret void 67} 68 69define void @setto(i32* %P, i32 %V) { 70 store i32 %V, i32* %P 71 ret void 72} 73 74declare double @cos(double) 75 76define internal void @CTOR8() { 77 %X = call double @cos( double 0.000000e+00 ) ; <double> [#uses=1] 78 store double %X, double* @D 79 ret void 80} 81 82define i1 @accessor() { 83 %V = load i1* @CTORGV ; <i1> [#uses=1] 84 ret i1 %V 85} 86 87%struct.A = type { i32 } 88%struct.B = type { i32 (...)**, i8*, [4 x i8] } 89@GV1 = global %struct.B zeroinitializer, align 8 90@GV2 = constant [3 x i8*] [i8* inttoptr (i64 16 to i8*), i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64 }* null to i8*)] 91; CHECK-NOT: CTOR9 92define internal void @CTOR9() { 93entry: 94 %0 = bitcast %struct.B* @GV1 to i8* 95 %1 = getelementptr inbounds i8* %0, i64 16 96 %2 = bitcast i8* %1 to %struct.A* 97 %3 = bitcast %struct.B* @GV1 to i8*** 98 store i8** getelementptr inbounds ([3 x i8*]* @GV2, i64 1, i64 0), i8*** %3 99 ret void 100} 101