llvm.org GIT mirror llvm / 793d4a8
Changed profiling-tool-chain.ll test to use optimal-edge-profiling instead of edge-profiling, this is more useful since the loading of the optimal-edge-profiling is more complicated. The edge-profiling is tested in edge-profiling.ll where only the instrumentation is tested. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80791 91177308-0d34-0410-b5e6-96231b3b80d8 Andreas Neustifter 11 years ago
2 changed file(s) with 164 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
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-edge-profiling -o %t2
1 ; RUN: opt %t1 -insert-optimal-edge-profiling -o %t2
22 ; RUN: llvm-dis < %t2 | FileCheck --check-prefix=INST %s
33 ; RUN: rm -f llvmprof.out
44 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t2
55 ; RUN: lli -load %llvmlibsdir/profile_rt%shlibext %t2 1 2
66 ; RUN: llvm-prof -print-all-code %t1 | FileCheck --check-prefix=PROF %s
7 ; RUN: rm llvmprof.out
87
98 ; PROF: 1. 2/4 oneblock
109 ; PROF: 2. 2/4 main
3130 @.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1]
3231 @.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1]
3332 @.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1]
34 ; INST:@EdgeProfCounters
35 ; INST:[19 x i32]
36 ; INST:zeroinitializer
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]
3756
3857 ; PROF:;;; %oneblock called 2 times.
3958 ; PROF:;;;
6079 %i = alloca i32 ; [#uses=4]
6180 %0 = alloca i32 ; [#uses=2]
6281 ; INST:call
63 ; INST:@llvm_start_edge_profiling
64 ; INST:@EdgeProfCounters
82 ; INST:@llvm_start_opt_edge_profiling
83 ; INST:@OptEdgeProfCounters
6584 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
6685 store i32 %argc, i32* %argc_addr
6786 store i8** %argv, i8*** %argv_addr