1 ; RUN: llvm-as < %s | opt -insert-edge-profiling | llvm-dis | tee %t1 | FileCheck %s
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
13 ; CHECK:zeroinitializer
15 define void @oneblock() nounwind {
18 ; CHECK:%OldFuncCounter
21 ; CHECK:@EdgeProfCounters
24 ; CHECK:%NewFuncCounter
26 ; CHECK:%OldFuncCounter
28 ; CHECK:%NewFuncCounter
30 ; CHECK:@EdgeProfCounters
31 %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
35 declare i32 @puts(i8*)
37 define i32 @main(i32 %argc, i8** %argv) nounwind {
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]
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
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
63 store i32 0, i32* %j, align 4
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
75 %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
80 %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
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
91 bb6: ; preds = %bb5, %bb1
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
104 %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
107 bb9: ; preds = %bb8, %bb7
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
114 bb10: ; preds = %bb9, %entry
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
120 ; CHECK:label %bb10.bb11_crit_edge
122 ; CHECK:bb10.bb11_crit_edge:
126 bb11: ; preds = %bb10, %bb4
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
134 return: ; preds = %bb11
136 %retval12 = load i32* %retval ; <i32> [#uses=1]