1 ; Test the edge profiling instrumentation.
2 ; RUN: opt < %s -insert-edge-profiling -S | FileCheck %s
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
14 ; CHECK:zeroinitializer
16 define void @oneblock() nounwind {
19 ; CHECK:%OldFuncCounter
22 ; CHECK:@EdgeProfCounters
25 ; CHECK:%NewFuncCounter
27 ; CHECK:%OldFuncCounter
29 ; CHECK:%NewFuncCounter
31 ; CHECK:@EdgeProfCounters
32 %0 = call i32 @puts(i8* getelementptr inbounds ([12 x i8]* @.str, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
36 declare i32 @puts(i8*)
38 define i32 @main(i32 %argc, i8** %argv) nounwind {
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]
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
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
64 store i32 0, i32* %j, align 4
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
76 %6 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str2, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
81 %7 = call i32 @puts(i8* getelementptr inbounds ([9 x i8]* @.str3, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
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
92 bb6: ; preds = %bb5, %bb1
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
105 %14 = call i32 @puts(i8* getelementptr inbounds ([10 x i8]* @.str5, i64 0, i64 0)) nounwind ; <i32> [#uses=0]
108 bb9: ; preds = %bb8, %bb7
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
115 bb10: ; preds = %bb9, %entry
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
121 ; CHECK:label %bb10.bb11_crit_edge
123 ; CHECK:bb10.bb11_crit_edge:
127 bb11: ; preds = %bb10, %bb4
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
135 return: ; preds = %bb11
137 %retval12 = load i32* %retval ; <i32> [#uses=1]