-; RUN: llvm-as < %s | opt -globalopt -disable-output &&
; RUN: llvm-as < %s | opt -globalopt | llvm-dis | not grep CTOR
+@llvm.global_ctors = appending global [10 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 2147483647, void ()* null } ] ; <[10 x { i32, void ()* }]*> [#uses=0]
+@G = global i32 0 ; <i32*> [#uses=1]
+@G2 = global i32 0 ; <i32*> [#uses=1]
+@G3 = global i32 -123 ; <i32*> [#uses=2]
+@X = global { i32, [2 x i32] } { i32 0, [2 x i32] [ i32 17, i32 21 ] } ; <{ i32, [2 x i32] }*> [#uses=2]
+@Y = global i32 -1 ; <i32*> [#uses=2]
+@Z = global i32 123 ; <i32*> [#uses=1]
+@D = global double 0.000000e+00 ; <double*> [#uses=1]
+@CTORGV = internal global i1 false ; <i1*> [#uses=2]
+
+define internal void @CTOR1() {
+ ret void
+}
-%llvm.global_ctors = appending global [9 x { int, void ()* }] [
- { int, void ()* } { int 65535, void ()* %CTOR1 },
- { int, void ()* } { int 65535, void ()* %CTOR1 },
- { int, void ()* } { int 65535, void ()* %CTOR2 },
- { int, void ()* } { int 65535, void ()* %CTOR3 },
- { int, void ()* } { int 65535, void ()* %CTOR4 },
- { int, void ()* } { int 65535, void ()* %CTOR5 },
- { int, void ()* } { int 65535, void ()* %CTOR6 },
- { int, void ()* } { int 65535, void ()* %CTOR7 },
- { int, void ()* } { int 2147483647, void ()* null }
-]
-
-%G = global int 0
-%G2 = global int 0
-%G3 = global int -123
-
-%X = global {int, [2 x int]} { int 0, [2 x int] [ int 17, int 21] }
-
-%Y = global int -1
-
-%Z = global int 123
+define internal void @CTOR2() {
+ %A = add i32 1, 23 ; <i32> [#uses=1]
+ store i32 %A, i32* @G
+ store i1 true, i1* @CTORGV
+ ret void
+}
-%CTORGV = internal global bool false ;; Should become constant after eval
+define internal void @CTOR3() {
+ %X = or i1 true, false ; <i1> [#uses=1]
+ br label %Cont
-implementation
+Cont: ; preds = %0
+ br i1 %X, label %S, label %T
-internal void %CTOR1() { ;; noop ctor, remove.
- ret void
-}
+S: ; preds = %Cont
+ store i32 24, i32* @G2
+ ret void
-internal void %CTOR2() { ;; evaluate the store
- %A = add int 1, 23
- store int %A, int* %G
- store bool true, bool* %CTORGV
- ret void
+T: ; preds = %Cont
+ ret void
}
-internal void %CTOR3() {
- %X = or bool true, false
- br label %Cont
-Cont:
- br bool %X, label %S, label %T
-S:
- store int 24, int* %G2
- ret void
-T:
+define internal void @CTOR4() {
+ %X = load i32* @G3 ; <i32> [#uses=1]
+ %Y = add i32 %X, 123 ; <i32> [#uses=1]
+ store i32 %Y, i32* @G3
ret void
}
-internal void %CTOR4() {
- %X = load int* %G3
- %Y = add int %X, 123
- store int %Y, int* %G3
+define internal void @CTOR5() {
+ %X.2p = getelementptr { i32, [2 x i32] }* @X, i32 0, i32 1, i32 0 ; <i32*> [#uses=2]
+ %X.2 = load i32* %X.2p ; <i32> [#uses=1]
+ %X.1p = getelementptr { i32, [2 x i32] }* @X, i32 0, i32 0 ; <i32*> [#uses=1]
+ store i32 %X.2, i32* %X.1p
+ store i32 42, i32* %X.2p
ret void
}
-internal void %CTOR5() {
- %X.2p = getelementptr {int,[2 x int]}* %X, int 0, uint 1, int 0
- %X.2 = load int* %X.2p
- %X.1p = getelementptr {int,[2 x int]}* %X, int 0, uint 0
- store int %X.2, int* %X.1p
- store int 42, int* %X.2p
+define internal void @CTOR6() {
+ %A = alloca i32 ; <i32*> [#uses=2]
+ %y = load i32* @Y ; <i32> [#uses=1]
+ store i32 %y, i32* %A
+ %Av = load i32* %A ; <i32> [#uses=1]
+ %Av1 = add i32 %Av, 1 ; <i32> [#uses=1]
+ store i32 %Av1, i32* @Y
ret void
}
-internal void %CTOR6() {
- %A = alloca int
- %y = load int* %Y
- store int %y, int* %A
- %Av = load int* %A
- %Av1 = add int %Av, 1
- store int %Av1, int* %Y
+define internal void @CTOR7() {
+ call void @setto( i32* @Z, i32 0 )
ret void
}
-internal void %CTOR7() {
- call void %setto(int* %Z, int 0)
+define void @setto(i32* %P, i32 %V) {
+ store i32 %V, i32* %P
ret void
}
-void %setto(int* %P, int %V) {
- store int %V, int* %P
+declare double @cos(double)
+
+define internal void @CTOR8() {
+ %X = call double @cos( double 1.000000e+00 ) ; <double> [#uses=1]
+ store double %X, double* @D
ret void
}
-bool %accessor() {
- %V = load bool* %CTORGV ;; constant true
- ret bool %V
+define i1 @accessor() {
+ %V = load i1* @CTORGV ; <i1> [#uses=1]
+ ret i1 %V
}