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