blob: cbaf47617fb6ced98b8db1701508b0e015d24191 [file] [log] [blame]
John Bauman66b8ab22014-05-06 15:57:45 -04001; Test the edge profiling instrumentation.
2; RUN: opt < %s -insert-edge-profiling -S | FileCheck %s
3
4; ModuleID = '<stdin>'
5
6@.str = private constant [12 x i8] c"hello world\00", align 1 ; <[12 x i8]*> [#uses=1]
7@.str1 = private constant [6 x i8] c"franz\00", align 1 ; <[6 x i8]*> [#uses=1]
8@.str2 = private constant [9 x i8] c"argc > 2\00", align 1 ; <[9 x i8]*> [#uses=1]
9@.str3 = private constant [9 x i8] c"argc = 1\00", align 1 ; <[9 x i8]*> [#uses=1]
10@.str4 = private constant [6 x i8] c"fritz\00", align 1 ; <[6 x i8]*> [#uses=1]
11@.str5 = private constant [10 x i8] c"argc <= 1\00", align 1 ; <[10 x i8]*> [#uses=1]
12; CHECK:@EdgeProfCounters
13; CHECK:[19 x i32]
14; CHECK:zeroinitializer
15
16define void @oneblock() nounwind {
17entry:
18; CHECK:entry:
19; CHECK:%OldFuncCounter
20; CHECK:load
21; CHECK:getelementptr
22; CHECK:@EdgeProfCounters
23; CHECK:i32 0
24; CHECK:i32 0
25; CHECK:%NewFuncCounter
26; CHECK:add
27; CHECK:%OldFuncCounter
28; CHECK:store
29; CHECK:%NewFuncCounter
30; CHECK:getelementptr
31; CHECK:@EdgeProfCounters
32 %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
33 ret void
34}
35
36declare i32 @puts(i8*)
37
38define i32 @main(i32 %argc, i8** %argv) nounwind {
39entry:
40; CHECK:entry:
41 %argc_addr = alloca i32 ; <i32*> [#uses=4]
42 %argv_addr = alloca i8** ; <i8***> [#uses=1]
43 %retval = alloca i32 ; <i32*> [#uses=2]
44 %j = alloca i32 ; <i32*> [#uses=4]
45 %i = alloca i32 ; <i32*> [#uses=4]
46 %0 = alloca i32 ; <i32*> [#uses=2]
47; CHECK:call
48; CHECK:@llvm_start_edge_profiling
49; CHECK:@EdgeProfCounters
50 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
51 store i32 %argc, i32* %argc_addr
52 store i8** %argv, i8*** %argv_addr
53 store i32 0, i32* %i, align 4
54 br label %bb10
55
56bb: ; preds = %bb10
57; CHECK:bb:
58 %1 = load i32* %argc_addr, align 4 ; <i32> [#uses=1]
59 %2 = icmp sgt i32 %1, 1 ; <i1> [#uses=1]
60 br i1 %2, label %bb1, label %bb8
61
62bb1: ; preds = %bb
63; CHECK:bb1:
64 store i32 0, i32* %j, align 4
65 br label %bb6
66
67bb2: ; preds = %bb6
68; CHECK:bb2:
69 %3 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
70 %4 = load i32* %argc_addr, align 4 ; <i32> [#uses=1]
71 %5 = icmp sgt i32 %4, 2 ; <i1> [#uses=1]
72 br i1 %5, label %bb3, label %bb4
73
74bb3: ; preds = %bb2
75; CHECK:bb3:
76 %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
77 br label %bb5
78
79bb4: ; preds = %bb2
80; CHECK:bb4:
81 %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
82 br label %bb11
83
84bb5: ; preds = %bb3
85; CHECK:bb5:
86 %8 = call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str4, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
87 %9 = load i32* %j, align 4 ; <i32> [#uses=1]
88 %10 = add nsw i32 %9, 1 ; <i32> [#uses=1]
89 store i32 %10, i32* %j, align 4
90 br label %bb6
91
92bb6: ; preds = %bb5, %bb1
93; CHECK:bb6:
94 %11 = load i32* %j, align 4 ; <i32> [#uses=1]
95 %12 = load i32* %argc_addr, align 4 ; <i32> [#uses=1]
96 %13 = icmp slt i32 %11, %12 ; <i1> [#uses=1]
97 br i1 %13, label %bb2, label %bb7
98
99bb7: ; preds = %bb6
100; CHECK:bb7:
101 br label %bb9
102
103bb8: ; preds = %bb
104; CHECK:bb8:
105 %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
106 br label %bb9
107
108bb9: ; preds = %bb8, %bb7
109; CHECK:bb9:
110 %15 = load i32* %i, align 4 ; <i32> [#uses=1]
111 %16 = add nsw i32 %15, 1 ; <i32> [#uses=1]
112 store i32 %16, i32* %i, align 4
113 br label %bb10
114
115bb10: ; preds = %bb9, %entry
116; CHECK:bb10:
117 %17 = load i32* %i, align 4 ; <i32> [#uses=1]
118 %18 = icmp ne i32 %17, 3 ; <i1> [#uses=1]
119 br i1 %18, label %bb, label %bb11
120; CHECK:br
121; CHECK:label %bb10.bb11_crit_edge
122
123; CHECK:bb10.bb11_crit_edge:
124; CHECK:br
125; CHECK:label %bb11
126
127bb11: ; preds = %bb10, %bb4
128; CHECK:bb11:
129 call void @oneblock() nounwind
130 store i32 0, i32* %0, align 4
131 %19 = load i32* %0, align 4 ; <i32> [#uses=1]
132 store i32 %19, i32* %retval, align 4
133 br label %return
134
135return: ; preds = %bb11
136; CHECK:return:
137 %retval12 = load i32* %retval ; <i32> [#uses=1]
138 ret i32 %retval12
139}