Too soon to commit, revert.
[oota-llvm.git] / test / Transforms / GlobalOpt / ctor-list-opt.ll
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -globalopt -disable-output &&
2 ; RUN: llvm-upgrade < %s | llvm-as | opt -globalopt | llvm-dis | not grep CTOR
3
4 %llvm.global_ctors = appending global [10 x { int, void ()* }] [ 
5   { int, void ()* } { int 65535, void ()* %CTOR1 },
6   { int, void ()* } { int 65535, void ()* %CTOR1 },
7   { int, void ()* } { int 65535, void ()* %CTOR2 },
8   { int, void ()* } { int 65535, void ()* %CTOR3 },
9   { int, void ()* } { int 65535, void ()* %CTOR4 },
10   { int, void ()* } { int 65535, void ()* %CTOR5 },
11   { int, void ()* } { int 65535, void ()* %CTOR6 },
12   { int, void ()* } { int 65535, void ()* %CTOR7 },
13   { int, void ()* } { int 65535, void ()* %CTOR8 },
14   { int, void ()* } { int 2147483647, void ()* null }
15 ]
16
17 %G = global int 0
18 %G2 = global int 0
19 %G3 = global int -123
20 %X = global {int, [2 x int]} { int 0, [2 x int] [ int 17, int 21] }
21 %Y = global int -1
22 %Z = global int 123
23 %D = global double 0.0
24
25 %CTORGV = internal global bool false    ;; Should become constant after eval
26
27 implementation
28
29 internal void %CTOR1() {   ;; noop ctor, remove.
30         ret void
31 }
32
33 internal void %CTOR2() {   ;; evaluate the store
34         %A = add int 1, 23
35         store int %A, int* %G
36         store bool true, bool* %CTORGV
37         ret void
38 }
39
40 internal void %CTOR3() {
41         %X = or bool true, false
42         br label %Cont
43 Cont:
44         br bool %X, label %S, label %T
45 S:
46         store int 24, int* %G2
47         ret void
48 T:
49         ret void
50 }
51
52 internal void %CTOR4() {
53         %X = load int* %G3
54         %Y = add int %X, 123
55         store int %Y, int* %G3
56         ret void
57 }
58
59 internal void %CTOR5() {
60         %X.2p = getelementptr {int,[2 x int]}* %X, int 0, uint 1, int 0
61         %X.2 = load int* %X.2p
62         %X.1p = getelementptr {int,[2 x int]}* %X, int 0, uint 0
63         store int %X.2, int* %X.1p
64         store int 42, int* %X.2p
65         ret void
66 }
67
68 internal void %CTOR6() {
69         %A = alloca int
70         %y = load int* %Y
71         store int %y, int* %A
72         %Av = load int* %A
73         %Av1 = add int %Av, 1
74         store int %Av1, int* %Y
75         ret void
76 }
77
78 internal void %CTOR7() {
79         call void %setto(int* %Z, int 0)
80         ret void
81 }
82
83 void %setto(int* %P, int %V) {
84         store int %V, int* %P
85         ret void
86 }
87
88 declare double %cos(double)
89
90 internal void %CTOR8() {
91         %X = call double %cos(double 1.0)
92         store double %X, double* %D
93         ret void
94 }
95 bool %accessor() {
96         %V = load bool* %CTORGV   ;; constant true
97         ret bool %V
98 }