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