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