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