llvm.org GIT mirror llvm / 3a22ff3
Reapply profiling tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80908 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 11 years ago
3 changed file(s) with 341 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 load_lib llvm.exp
1
2 RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
3
0 ; RUN: llvm-as < %s | opt -insert-edge-profiling | llvm-dis | tee %t1 | FileCheck %s
1
2 ; ModuleID = ''
3
4 @.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1]
5 @.str1 = private constant [6 x i8] c"franz\00", align 1 ; <[6 x i8]*> [#uses=1]
6 @.str2 = private constant [9 x i8] c"argc > 2\00", align 1 ; <[9 x i8]*> [#uses=1]
7 @.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1]
8 @.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1]
9 @.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1]
10 ; CHECK:@EdgeProfCounters
11 ; CHECK:[19 x i32]
12 ; CHECK:zeroinitializer
13
14 define void @oneblock() nounwind {
15 entry:
16 ; CHECK:entry:
17 ; CHECK:%OldFuncCounter
18 ; CHECK:load
19 ; CHECK:getelementptr
20 ; CHECK:@EdgeProfCounters
21 ; CHECK:i32 0
22 ; CHECK:i32 0
23 ; CHECK:%NewFuncCounter
24 ; CHECK:add
25 ; CHECK:%OldFuncCounter
26 ; CHECK:store
27 ; CHECK:%NewFuncCounter
28 ; CHECK:getelementptr
29 ; CHECK:@EdgeProfCounters
30 %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; [#uses=0]
31 ret void
32 }
33
34 declare i32 @puts(i8*)
35
36 define i32 @main(i32 %argc, i8** %argv) nounwind {
37 entry:
38 ; CHECK:entry:
39 %argc_addr = alloca i32 ; [#uses=4]
40 %argv_addr = alloca i8** ; [#uses=1]
41 %retval = alloca i32 ; [#uses=2]
42 %j = alloca i32 ; [#uses=4]
43 %i = alloca i32 ; [#uses=4]
44 %0 = alloca i32 ; [#uses=2]
45 ; CHECK:call
46 ; CHECK:@llvm_start_edge_profiling
47 ; CHECK:@EdgeProfCounters
48 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
49 store i32 %argc, i32* %argc_addr
50 store i8** %argv, i8*** %argv_addr
51 store i32 0, i32* %i, align 4
52 br label %bb10
53
54 bb: ; preds = %bb10
55 ; CHECK:bb:
56 %1 = load i32* %argc_addr, align 4 ; [#uses=1]
57 %2 = icmp sgt i32 %1, 1 ; [#uses=1]
58 br i1 %2, label %bb1, label %bb8
59
60 bb1: ; preds = %bb
61 ; CHECK:bb1:
62 store i32 0, i32* %j, align 4
63 br label %bb6
64
65 bb2: ; preds = %bb6
66 ; CHECK:bb2:
67 %3 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i64 0, i64 0)) nounwind ; [#uses=0]
68 %4 = load i32* %argc_addr, align 4 ; [#uses=1]
69 %5 = icmp sgt i32 %4, 2 ; [#uses=1]
70 br i1 %5, label %bb3, label %bb4
71
72 bb3: ; preds = %bb2
73 ; CHECK:bb3:
74 %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; [#uses=0]
75 br label %bb5
76
77 bb4: ; preds = %bb2
78 ; CHECK:bb4:
79 %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; [#uses=0]
80 br label %bb11
81
82 bb5: ; preds = %bb3
83 ; CHECK:bb5:
84 %8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0)) nounwind ; [#uses=0]
85 %9 = load i32* %j, align 4 ; [#uses=1]
86 %10 = add nsw i32 %9, 1 ; [#uses=1]
87 store i32 %10, i32* %j, align 4
88 br label %bb6
89
90 bb6: ; preds = %bb5, %bb1
91 ; CHECK:bb6:
92 %11 = load i32* %j, align 4 ; [#uses=1]
93 %12 = load i32* %argc_addr, align 4 ; [#uses=1]
94 %13 = icmp slt i32 %11, %12 ; [#uses=1]
95 br i1 %13, label %bb2, label %bb7
96
97 bb7: ; preds = %bb6
98 ; CHECK:bb7:
99 br label %bb9
100
101 bb8: ; preds = %bb
102 ; CHECK:bb8:
103 %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; [#uses=0]
104 br label %bb9
105
106 bb9: ; preds = %bb8, %bb7
107 ; CHECK:bb9:
108 %15 = load i32* %i, align 4 ; [#uses=1]
109 %16 = add nsw i32 %15, 1 ; [#uses=1]
110 store i32 %16, i32* %i, align 4
111 br label %bb10
112
113 bb10: ; preds = %bb9, %entry
114 ; CHECK:bb10:
115 %17 = load i32* %i, align 4 ; [#uses=1]
116 %18 = icmp ne i32 %17, 3 ; [#uses=1]
117 br i1 %18, label %bb, label %bb11
118 ; CHECK:br
119 ; CHECK:label %bb10.bb11_crit_edge
120
121 ; CHECK:bb10.bb11_crit_edge:
122 ; CHECK:br
123 ; CHECK:label %bb11
124
125 bb11: ; preds = %bb10, %bb4
126 ; CHECK:bb11:
127 call void @oneblock() nounwind
128 store i32 0, i32* %0, align 4
129 %19 = load i32* %0, align 4 ; [#uses=1]
130 store i32 %19, i32* %retval, align 4
131 br label %return
132
133 return: ; preds = %bb11
134 ; CHECK:return:
135 %retval12 = load i32* %retval ; [#uses=1]
136 ret i32 %retval12
137 }
0 ; RUN: llvm-as %s -o %t1
1 ; RUN: opt %t1 -insert-optimal-edge-profiling -o %t2
2 ; RUN: llvm-dis < %t2 | FileCheck --check-prefix=INST %s
3 ; RUN: rm -f llvmprof.out
4 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t2
5 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t2 1 2
6 ; RUN: llvm-prof -print-all-code %t1 | FileCheck --check-prefix=PROF %s
7
8 ; PROF: 1. 2/4 oneblock
9 ; PROF: 2. 2/4 main
10 ; PROF: 1. 15.7895% 12/76 main() - bb6
11 ; PROF: 2. 11.8421% 9/76 main() - bb2
12 ; PROF: 3. 11.8421% 9/76 main() - bb3
13 ; PROF: 4. 11.8421% 9/76 main() - bb5
14 ; PROF: 5. 10.5263% 8/76 main() - bb10
15 ; PROF: 6. 7.89474% 6/76 main() - bb
16 ; PROF: 7. 7.89474% 6/76 main() - bb9
17 ; PROF: 8. 3.94737% 3/76 main() - bb1
18 ; PROF: 9. 3.94737% 3/76 main() - bb7
19 ; PROF: 10. 3.94737% 3/76 main() - bb8
20 ; PROF: 11. 2.63158% 2/76 oneblock() - entry
21 ; PROF: 12. 2.63158% 2/76 main() - entry
22 ; PROF: 13. 2.63158% 2/76 main() - bb11
23 ; PROF: 14. 2.63158% 2/76 main() - return
24
25 ; ModuleID = ''
26
27 @.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1]
28 @.str1 = private constant [6 x i8] c"franz\00", align 1 ; <[6 x i8]*> [#uses=1]
29 @.str2 = private constant [9 x i8] c"argc > 2\00", align 1 ; <[9 x i8]*> [#uses=1]
30 @.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1]
31 @.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1]
32 @.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1]
33 ; INST:@OptEdgeProfCounters
34 ; INST:[21 x i32]
35 ; INST:[i32 0,
36 ; INST:i32 -1,
37 ; INST:i32 -1,
38 ; INST:i32 -1,
39 ; INST:i32 -1,
40 ; INST:i32 -1,
41 ; INST:i32 -1,
42 ; INST:i32 -1,
43 ; INST:i32 -1,
44 ; INST:i32 0,
45 ; INST:i32 0,
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 0,
54 ; INST:i32 -1,
55 ; INST:i32 -1]
56
57 ; PROF:;;; %oneblock called 2 times.
58 ; PROF:;;;
59 define void @oneblock() nounwind {
60 entry:
61 ; PROF:entry:
62 ; PROF: ;;; Basic block executed 2 times.
63 %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; [#uses=0]
64 ret void
65 }
66
67 declare i32 @puts(i8*)
68
69 ; PROF:;;; %main called 2 times.
70 ; PROF:;;;
71 define i32 @main(i32 %argc, i8** %argv) nounwind {
72 entry:
73 ; PROF:entry:
74 ; PROF: ;;; Basic block executed 2 times.
75 %argc_addr = alloca i32 ; [#uses=4]
76 %argv_addr = alloca i8** ; [#uses=1]
77 %retval = alloca i32 ; [#uses=2]
78 %j = alloca i32 ; [#uses=4]
79 %i = alloca i32 ; [#uses=4]
80 %0 = alloca i32 ; [#uses=2]
81 ; INST:call
82 ; INST:@llvm_start_opt_edge_profiling
83 ; INST:@OptEdgeProfCounters
84 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
85 store i32 %argc, i32* %argc_addr
86 store i8** %argv, i8*** %argv_addr
87 store i32 0, i32* %i, align 4
88 br label %bb10
89 ; PROF: ;;; Out-edge counts: [2.000000e+00 -> bb10]
90
91 bb: ; preds = %bb10
92 ; PROF:bb:
93 ; PROF: ;;; Basic block executed 6 times.
94 %1 = load i32* %argc_addr, align 4 ; [#uses=1]
95 %2 = icmp sgt i32 %1, 1 ; [#uses=1]
96 br i1 %2, label %bb1, label %bb8
97 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb1] [3.000000e+00 -> bb8]
98
99 bb1: ; preds = %bb
100 ; PROF:bb1:
101 ; PROF: ;;; Basic block executed 3 times.
102 store i32 0, i32* %j, align 4
103 br label %bb6
104 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb6]
105
106 bb2: ; preds = %bb6
107 ; PROF:bb2:
108 ; PROF: ;;; Basic block executed 9 times.
109 %3 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i64 0, i64 0)) nounwind ; [#uses=0]
110 %4 = load i32* %argc_addr, align 4 ; [#uses=1]
111 %5 = icmp sgt i32 %4, 2 ; [#uses=1]
112 br i1 %5, label %bb3, label %bb4
113 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb3]
114
115 bb3: ; preds = %bb2
116 ; PROF:bb3:
117 ; PROF: ;;; Basic block executed 9 times.
118 %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; [#uses=0]
119 br label %bb5
120 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb5]
121
122 bb4: ; preds = %bb2
123 ; PROF:bb4:
124 ; PROF: ;;; Never executed!
125 %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; [#uses=0]
126 br label %bb11
127
128 bb5: ; preds = %bb3
129 ; PROF:bb5:
130 ; PROF: ;;; Basic block executed 9 times.
131 %8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0)) nounwind ; [#uses=0]
132 %9 = load i32* %j, align 4 ; [#uses=1]
133 %10 = add nsw i32 %9, 1 ; [#uses=1]
134 store i32 %10, i32* %j, align 4
135 br label %bb6
136 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb6]
137
138 bb6: ; preds = %bb5, %bb1
139 ; PROF:bb6:
140 ; PROF: ;;; Basic block executed 12 times.
141 %11 = load i32* %j, align 4 ; [#uses=1]
142 %12 = load i32* %argc_addr, align 4 ; [#uses=1]
143 %13 = icmp slt i32 %11, %12 ; [#uses=1]
144 br i1 %13, label %bb2, label %bb7
145 ; PROF: ;;; Out-edge counts: [9.000000e+00 -> bb2] [3.000000e+00 -> bb7]
146
147 bb7: ; preds = %bb6
148 ; PROF:bb7:
149 ; PROF: ;;; Basic block executed 3 times.
150 br label %bb9
151 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb9]
152
153 bb8: ; preds = %bb
154 ; PROF:bb8:
155 ; PROF: ;;; Basic block executed 3 times.
156 %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; [#uses=0]
157 br label %bb9
158 ; PROF: ;;; Out-edge counts: [3.000000e+00 -> bb9]
159
160 bb9: ; preds = %bb8, %bb7
161 ; PROF:bb9:
162 ; PROF: ;;; Basic block executed 6 times.
163 %15 = load i32* %i, align 4 ; [#uses=1]
164 %16 = add nsw i32 %15, 1 ; [#uses=1]
165 store i32 %16, i32* %i, align 4
166 br label %bb10
167 ; PROF: ;;; Out-edge counts: [6.000000e+00 -> bb10]
168
169 bb10: ; preds = %bb9, %entry
170 ; PROF:bb10:
171 ; PROF: ;;; Basic block executed 8 times.
172 %17 = load i32* %i, align 4 ; [#uses=1]
173 %18 = icmp ne i32 %17, 3 ; [#uses=1]
174 br i1 %18, label %bb, label %bb11
175 ; INST:br
176 ; INST:label %bb10.bb11_crit_edge
177 ; PROF: ;;; Out-edge counts: [6.000000e+00 -> bb] [2.000000e+00 -> bb11]
178
179 ; INST:bb10.bb11_crit_edge:
180 ; INST:br
181 ; INST:label %bb11
182
183 bb11: ; preds = %bb10, %bb4
184 ; PROF:bb11:
185 ; PROF: ;;; Basic block executed 2 times.
186 call void @oneblock() nounwind
187 store i32 0, i32* %0, align 4
188 %19 = load i32* %0, align 4 ; [#uses=1]
189 store i32 %19, i32* %retval, align 4
190 br label %return
191 ; PROF: ;;; Out-edge counts: [2.000000e+00 -> return]
192
193 return: ; preds = %bb11
194 ; PROF:return:
195 ; PROF: ;;; Basic block executed 2 times.
196 %retval12 = load i32* %retval ; [#uses=1]
197 ret i32 %retval12
198 }