Revert "--- Reverse-merging r80908 into '.':", I already "fixed" this.
[oota-llvm.git] / test / Analysis / Profiling / profiling-tool-chain.ll
1 ; RUN: llvm-as %s -o %t1
2 ; RUN: opt %t1 -insert-optimal-edge-profiling -o %t2
3
4 ; FIXME: These parts of the test are disabled for now, they aren't working on
5 ; llvm-gcc-x86_64-darwin10-selfhost.
6
7 ; RUX: llvm-dis < %t2 | FileCheck --check-prefix=INST %s
8 ; RUX: rm -f llvmprof.out
9 ; RUX: lli -load %llvmlibsdir/profile_rt%shlibext %t2
10 ; RUX: lli -load %llvmlibsdir/profile_rt%shlibext %t2 1 2
11 ; RUX: llvm-prof -print-all-code %t1 | FileCheck --check-prefix=PROF %s
12
13 ; PROF:  1.     2/4 oneblock
14 ; PROF:  2.     2/4 main
15 ; PROF:  1. 15.7895%    12/76   main() - bb6
16 ; PROF:  2. 11.8421%     9/76   main() - bb2
17 ; PROF:  3. 11.8421%     9/76   main() - bb3
18 ; PROF:  4. 11.8421%     9/76   main() - bb5
19 ; PROF:  5. 10.5263%     8/76   main() - bb10
20 ; PROF:  6. 7.89474%     6/76   main() - bb
21 ; PROF:  7. 7.89474%     6/76   main() - bb9
22 ; PROF:  8. 3.94737%     3/76   main() - bb1
23 ; PROF:  9. 3.94737%     3/76   main() - bb7
24 ; PROF: 10. 3.94737%     3/76   main() - bb8
25 ; PROF: 11. 2.63158%     2/76   oneblock() - entry
26 ; PROF: 12. 2.63158%     2/76   main() - entry
27 ; PROF: 13. 2.63158%     2/76   main() - bb11
28 ; PROF: 14. 2.63158%     2/76   main() - return
29
30 ; ModuleID = '<stdin>'
31
32 @.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1]
33 @.str1 = private constant [6 x i8] c"franz\00", align 1 ; <[6 x i8]*> [#uses=1]
34 @.str2 = private constant [9 x i8] c"argc > 2\00", align 1 ; <[9 x i8]*> [#uses=1]
35 @.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1]
36 @.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1]
37 @.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1]
38 ; INST:@OptEdgeProfCounters
39 ; INST:[21 x i32]
40 ; INST:[i32 0,
41 ; INST:i32 -1,
42 ; INST:i32 -1,
43 ; INST:i32 -1,
44 ; INST:i32 -1,
45 ; INST:i32 -1,
46 ; INST:i32 -1,
47 ; INST:i32 -1,
48 ; INST:i32 -1,
49 ; INST:i32 0,
50 ; INST:i32 0,
51 ; INST:i32 -1,
52 ; INST:i32 -1,
53 ; INST:i32 -1,
54 ; INST:i32 0,
55 ; INST:i32 0,
56 ; INST:i32 -1,
57 ; INST:i32 -1,
58 ; INST:i32 0,
59 ; INST:i32 -1,
60 ; INST:i32 -1]
61
62 ; PROF:;;; %oneblock called 2 times.
63 ; PROF:;;;
64 define void @oneblock() nounwind {
65 entry:
66 ; PROF:entry:
67 ; PROF: ;;; Basic block executed 2 times.
68   %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
69   ret void
70 }
71
72 declare i32 @puts(i8*)
73
74 ; PROF:;;; %main called 2 times.
75 ; PROF:;;;
76 define i32 @main(i32 %argc, i8** %argv) nounwind {
77 entry:
78 ; PROF:entry:
79 ; PROF: ;;; Basic block executed 2 times.
80   %argc_addr = alloca i32                         ; <i32*> [#uses=4]
81   %argv_addr = alloca i8**                        ; <i8***> [#uses=1]
82   %retval = alloca i32                            ; <i32*> [#uses=2]
83   %j = alloca i32                                 ; <i32*> [#uses=4]
84   %i = alloca i32                                 ; <i32*> [#uses=4]
85   %0 = alloca i32                                 ; <i32*> [#uses=2]
86 ; INST:call 
87 ; INST:@llvm_start_opt_edge_profiling
88 ; INST:@OptEdgeProfCounters
89   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
90   store i32 %argc, i32* %argc_addr
91   store i8** %argv, i8*** %argv_addr
92   store i32 0, i32* %i, align 4
93   br label %bb10
94 ; PROF: ;;; Out-edge counts: [2.000000e+00 -> bb10]
95
96 bb:                                               ; preds = %bb10
97 ; PROF:bb:
98 ; PROF: ;;; Basic block executed 6 times.
99   %1 = load i32* %argc_addr, align 4              ; <i32> [#uses=1]
100   %2 = icmp sgt i32 %1, 1                         ; <i1> [#uses=1]
101   br i1 %2, label %bb1, label %bb8
102 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb1] [3.000000e+00 -> bb8]
103
104 bb1:                                              ; preds = %bb
105 ; PROF:bb1:
106 ; PROF: ;;; Basic block executed 3 times.
107   store i32 0, i32* %j, align 4
108   br label %bb6
109 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb6]
110
111 bb2:                                              ; preds = %bb6
112 ; PROF:bb2:
113 ; PROF: ;;; Basic block executed 9 times.
114   %3 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
115   %4 = load i32* %argc_addr, align 4              ; <i32> [#uses=1]
116   %5 = icmp sgt i32 %4, 2                         ; <i1> [#uses=1]
117   br i1 %5, label %bb3, label %bb4
118 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb3]
119
120 bb3:                                              ; preds = %bb2
121 ; PROF:bb3:
122 ; PROF: ;;; Basic block executed 9 times.
123   %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
124   br label %bb5
125 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb5]
126
127 bb4:                                              ; preds = %bb2
128 ; PROF:bb4:
129 ; PROF: ;;; Never executed!
130   %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
131   br label %bb11
132
133 bb5:                                              ; preds = %bb3
134 ; PROF:bb5:
135 ; PROF: ;;; Basic block executed 9 times.
136   %8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
137   %9 = load i32* %j, align 4                      ; <i32> [#uses=1]
138   %10 = add nsw i32 %9, 1                         ; <i32> [#uses=1]
139   store i32 %10, i32* %j, align 4
140   br label %bb6
141 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb6]
142
143 bb6:                                              ; preds = %bb5, %bb1
144 ; PROF:bb6:
145 ; PROF: ;;; Basic block executed 12 times.
146   %11 = load i32* %j, align 4                     ; <i32> [#uses=1]
147   %12 = load i32* %argc_addr, align 4             ; <i32> [#uses=1]
148   %13 = icmp slt i32 %11, %12                     ; <i1> [#uses=1]
149   br i1 %13, label %bb2, label %bb7
150 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb2] [3.000000e+00 -> bb7]
151
152 bb7:                                              ; preds = %bb6
153 ; PROF:bb7:
154 ; PROF: ;;; Basic block executed 3 times.
155   br label %bb9
156 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb9]
157
158 bb8:                                              ; preds = %bb
159 ; PROF:bb8:
160 ; PROF: ;;; Basic block executed 3 times.
161   %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
162   br label %bb9
163 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb9]
164
165 bb9:                                              ; preds = %bb8, %bb7
166 ; PROF:bb9:
167 ; PROF: ;;; Basic block executed 6 times.
168   %15 = load i32* %i, align 4                     ; <i32> [#uses=1]
169   %16 = add nsw i32 %15, 1                        ; <i32> [#uses=1]
170   store i32 %16, i32* %i, align 4
171   br label %bb10
172 ; PROF: ;;; Out-edge counts: [6.000000e+00 -> bb10]
173
174 bb10:                                             ; preds = %bb9, %entry
175 ; PROF:bb10:
176 ; PROF: ;;; Basic block executed 8 times.
177   %17 = load i32* %i, align 4                     ; <i32> [#uses=1]
178   %18 = icmp ne i32 %17, 3                        ; <i1> [#uses=1]
179   br i1 %18, label %bb, label %bb11
180 ; INST:br
181 ; INST:label %bb10.bb11_crit_edge
182 ; PROF: ;;; Out-edge counts: [6.000000e+00 -> bb] [2.000000e+00 -> bb11]
183
184 ; INST:bb10.bb11_crit_edge:
185 ; INST:br
186 ; INST:label %bb11
187
188 bb11:                                             ; preds = %bb10, %bb4
189 ; PROF:bb11:
190 ; PROF: ;;; Basic block executed 2 times.
191   call void @oneblock() nounwind
192   store i32 0, i32* %0, align 4
193   %19 = load i32* %0, align 4                     ; <i32> [#uses=1]
194   store i32 %19, i32* %retval, align 4
195   br label %return
196 ; PROF: ;;; Out-edge counts: [2.000000e+00 -> return]
197
198 return:                                           ; preds = %bb11
199 ; PROF:return:
200 ; PROF: ;;; Basic block executed 2 times.
201   %retval12 = load i32* %retval                   ; <i32> [#uses=1]
202   ret i32 %retval12
203 }