1 ; RUN: llvm-as < %s | opt -insert-edge-profiling > %t1
2 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t1
3 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t1 1
4 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t1 1 2
5 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t1 1 2 3
6 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t1 1 2 3 4
7 ; RUN: mv llvmprof.out %t2
8 ; RUN: llvm-prof -print-all-code %t1 %t2 | tee %t3 | FileCheck %s
10 ; CHECK: 1. 19.5745% 46/235 main() - bb6
11 ; CHECK: 2. 15.7447% 37/235 main() - bb2
12 ; CHECK: 3. 15.3191% 36/235 main() - bb3
13 ; CHECK: 4. 15.3191% 36/235 main() - bb5
14 ; CHECK: 5. 7.23404% 17/235 main() - bb10
15 ; CHECK: 6. 5.53191% 13/235 main() - bb
16 ; CHECK: 7. 5.10638% 12/235 main() - bb9
17 ; CHECK: 8. 4.25532% 10/235 main() - bb1
18 ; CHECK: 9. 3.82979% 9/235 main() - bb7
19 ; CHECK: 10. 2.55319% 6/235 main() - bb11
20 ; CHECK: 11. 2.12766% 5/235 main() - entry
21 ; CHECK: 12. 1.70213% 4/235 main() - bb10.bb11_crit_edge
22 ; CHECK: 13. 1.2766% 3/235 main() - bb8
23 ; CHECK: 14. 0.425532% 1/235 main() - bb4
24 ; ModuleID = '<stdin>'
25 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"
26 target triple = "x86_64-unknown-linux-gnu"
27 @.str = internal constant [6 x i8] c"franz\00" ; <[6 x i8]*> [#uses=1]
28 @.str1 = internal constant [9 x i8] c"argc > 2\00" ; <[9 x i8]*> [#uses=1]
29 @.str2 = internal constant [9 x i8] c"argc = 1\00" ; <[9 x i8]*> [#uses=1]
30 @.str3 = internal constant [6 x i8] c"fritz\00" ; <[6 x i8]*> [#uses=1]
31 @.str4 = internal constant [10 x i8] c"argc <= 1\00" ; <[10 x i8]*> [#uses=1]
33 ; CHECK:;;; %main called 5 times.
35 define i32 @main(i32 %argc, i8** %argv) nounwind {
38 ; CHECK: ;;; Basic block executed 5 times.
39 %argc_addr = alloca i32 ; <i32*> [#uses=4]
40 %argv_addr = alloca i8** ; <i8***> [#uses=1]
41 %retval = alloca i32 ; <i32*> [#uses=2]
42 %j = alloca i32 ; <i32*> [#uses=4]
43 %i = alloca i32 ; <i32*> [#uses=4]
44 %0 = alloca i32 ; <i32*> [#uses=2]
45 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
46 store i32 %argc, i32* %argc_addr
47 store i8** %argv, i8*** %argv_addr
48 store i32 0, i32* %i, align 4
50 ; CHECK: ;;; Out-edge counts: [5.000000e+00 -> bb10]
54 ; CHECK: ;;; Basic block executed 13 times.
55 %1 = load i32* %argc_addr, align 4 ; <i32> [#uses=1]
56 %2 = icmp sgt i32 %1, 1 ; <i1> [#uses=1]
57 br i1 %2, label %bb1, label %bb8
58 ; CHECK: ;;; Out-edge counts: [1.000000e+01 -> bb1] [3.000000e+00 -> bb8]
62 ; CHECK: ;;; Basic block executed 10 times.
63 store i32 0, i32* %j, align 4
65 ; CHECK: ;;; Out-edge counts: [1.000000e+01 -> bb6]
69 ; CHECK: ;;; Basic block executed 37 times.
70 %3 = call i32 @puts(i8* getelementptr ([6 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
71 %4 = load i32* %argc_addr, align 4 ; <i32> [#uses=1]
72 %5 = icmp sgt i32 %4, 2 ; <i1> [#uses=1]
73 br i1 %5, label %bb3, label %bb4
74 ; CHECK: ;;; Out-edge counts: [3.600000e+01 -> bb3] [1.000000e+00 -> bb4]
78 ; CHECK: ;;; Basic block executed 36 times.
79 %6 = call i32 @puts(i8* getelementptr ([9 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
81 ; CHECK: ;;; Out-edge counts: [3.600000e+01 -> bb5]
85 ; CHECK: ;;; Basic block executed 1 times.
86 %7 = call i32 @puts(i8* getelementptr ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
88 ; CHECK: ;;; Out-edge counts: [1.000000e+00 -> bb11]
92 ; CHECK: ;;; Basic block executed 36 times.
93 %8 = call i32 @puts(i8* getelementptr ([6 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
94 %9 = load i32* %j, align 4 ; <i32> [#uses=1]
95 %10 = add i32 %9, 1 ; <i32> [#uses=1]
96 store i32 %10, i32* %j, align 4
98 ; CHECK: ;;; Out-edge counts: [3.600000e+01 -> bb6]
100 bb6: ; preds = %bb5, %bb1
102 ; CHECK: ;;; Basic block executed 46 times.
103 %11 = load i32* %j, align 4 ; <i32> [#uses=1]
104 %12 = load i32* %argc_addr, align 4 ; <i32> [#uses=1]
105 %13 = icmp slt i32 %11, %12 ; <i1> [#uses=1]
106 br i1 %13, label %bb2, label %bb7
107 ; CHECK: ;;; Out-edge counts: [3.700000e+01 -> bb2] [9.000000e+00 -> bb7]
111 ; CHECK: ;;; Basic block executed 9 times.
113 ; CHECK: ;;; Out-edge counts: [9.000000e+00 -> bb9]
117 ; CHECK: ;;; Basic block executed 3 times.
118 %14 = call i32 @puts(i8* getelementptr ([10 x i8]* @.str4, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
120 ; CHECK: ;;; Out-edge counts: [3.000000e+00 -> bb9]
122 bb9: ; preds = %bb8, %bb7
124 ; CHECK: ;;; Basic block executed 12 times.
125 %15 = load i32* %i, align 4 ; <i32> [#uses=1]
126 %16 = add i32 %15, 1 ; <i32> [#uses=1]
127 store i32 %16, i32* %i, align 4
129 ; CHECK: ;;; Out-edge counts: [1.200000e+01 -> bb10]
131 bb10: ; preds = %bb9, %entry
132 ; CHECK: ;;; Basic block executed 17 times.
133 %17 = load i32* %i, align 4 ; <i32> [#uses=1]
134 %18 = icmp ne i32 %17, 3 ; <i1> [#uses=1]
135 br i1 %18, label %bb, label %bb11
136 ; CHECK: ;;; Out-edge counts: [1.300000e+01 -> bb] [4.000000e+00 -> bb10.bb11_crit_edge]
137 ; CHECK: ;;; Basic block executed 4 times.
138 ; CHECK: ;;; Out-edge counts: [5.000000e+00 -> bb11]
140 bb11: ; preds = %bb10, %bb4
142 ; CHECK: ;;; Basic block executed 6 times.
143 store i32 0, i32* %0, align 4
144 %19 = load i32* %0, align 4 ; <i32> [#uses=1]
145 store i32 %19, i32* %retval, align 4
148 return: ; preds = %bb11
150 %retval12 = load i32* %retval ; <i32> [#uses=1]
154 declare i32 @puts(i8*)