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