1; RUN: opt < %s -globalopt -S | FileCheck %s 2; CHECK-NOT: CTOR 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 } 16] 17 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] 26 27define internal void @CTOR1() { 28 ret void 29} 30 31define internal void @CTOR2() { 32 %A = add i32 1, 23 ; <i32> [#uses=1] 33 store i32 %A, i32* @G 34 store i1 true, i1* @CTORGV 35 ret void 36} 37 38define internal void @CTOR3() { 39 %X = or i1 true, false ; <i1> [#uses=1] 40 br label %Cont 41 42Cont: ; preds = %0 43 br i1 %X, label %S, label %T 44 45S: ; preds = %Cont 46 store i32 24, i32* @G2 47 ret void 48 49T: ; preds = %Cont 50 ret void 51} 52 53define 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 57 ret void 58} 59 60define 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 66 ret void 67} 68 69define internal void @CTOR6() { 70 %A = alloca i32 ; <i32*> [#uses=2] 71 %y = load i32, i32* @Y ; <i32> [#uses=1] 72 store i32 %y, i32* %A 73 %Av = load i32, i32* %A ; <i32> [#uses=1] 74 %Av1 = add i32 %Av, 1 ; <i32> [#uses=1] 75 store i32 %Av1, i32* @Y 76 ret void 77} 78 79define internal void @CTOR7() { 80 call void @setto( i32* @Z, i32 0 ) 81 ret void 82} 83 84define void @setto(i32* %P, i32 %V) { 85 store i32 %V, i32* %P 86 ret void 87} 88 89declare double @cos(double) 90 91define internal void @CTOR8() { 92 %X = call double @cos( double 0.000000e+00 ) ; <double> [#uses=1] 93 store double %X, double* @D 94 ret void 95} 96 97define i1 @accessor() { 98 %V = load i1, i1* @CTORGV ; <i1> [#uses=1] 99 ret i1 %V 100} 101 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*)] 106; CHECK-NOT: CTOR9 107define internal void @CTOR9() { 108entry: 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 114 ret void 115} 116