• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s
2; RUN: opt < %s --passes=instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s
3
4$__llvm_profile_raw_version = comdat any
5
6@g = common local_unnamed_addr global i32 0, align 4
7@__llvm_profile_raw_version = constant i64 72057594037927940, comdat
8@__profn_foo = private constant [3 x i8] c"foo"
9
10define void @foo(i32 %arg) local_unnamed_addr {
11bb:
12  %tmp = add nsw i32 %arg, -1
13  br label %bb1
14
15bb1:                                              ; preds = %bb11, %bb
16  %tmp2 = phi i32 [ 0, %bb ], [ %tmp12, %bb11 ]
17  %tmp3 = icmp sgt i32 %tmp2, %arg
18  br i1 %tmp3, label %bb7, label %bb4
19
20bb4:                                              ; preds = %bb1
21  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 63969943867, i32 5, i32 1)
22  tail call void @bar(i32 1)
23  %tmp5 = load i32, i32* @g, align 4
24  %tmp6 = icmp sgt i32 %tmp5, 100
25  br i1 %tmp6, label %bb14, label %bb11
26
27bb7:                                              ; preds = %bb1
28  %tmp8 = icmp slt i32 %tmp2, %tmp
29  br i1 %tmp8, label %bb9, label %bb10
30
31bb9:                                              ; preds = %bb7
32  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 63969943867, i32 5, i32 2)
33  tail call void @bar(i32 2)
34  br label %bb11
35
36bb10:                                             ; preds = %bb7
37  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 63969943867, i32 5, i32 3)
38  tail call void @bar(i32 3)
39  br label %bb11
40
41bb11:                                             ; preds = %bb10, %bb9, %bb4
42  %tmp12 = add nuw nsw i32 %tmp2, 1
43  %tmp13 = icmp slt i32 %tmp2, 99
44  br i1 %tmp13, label %bb1, label %bb14
45
46bb14:                                             ; preds = %bb4.bb14_crit_edge, %bb11
47  tail call void @bar(i32 0)
48  br label %bb15
49; PROMO-LABEL: bb14:
50; PROMO: %[[MERGE1:[a-z0-9]+]] = phi {{.*}}
51; PROMO-NEXT: %[[MERGE2:[a-z0-9.]+]] = phi {{.*}}
52; PROMO-NEXT: %[[MERGE3:[a-z0-9.]+]] = phi {{.*}}
53; PROMO-NEXT: %[[PROMO3:[a-z0-9.]+]] = load{{.*}}@__profc_foo{{.*}}1)
54; PROMO-NEXT: {{.*}} = add {{.*}}%[[PROMO3]], %[[MERGE3]]
55; PROMO-NEXT: store{{.*}}@__profc_foo{{.*}}1)
56; PROMO-NEXT: %[[PROMO2:[a-z0-9.]+]] = load{{.*}}@__profc_foo{{.*}}2)
57; PROMO-NEXT: {{.*}} = add {{.*}}%[[PROMO2]], %[[MERGE2]]
58; PROMO-NEXT: store{{.*}}@__profc_foo{{.*}}2)
59; PROMO-NEXT: %[[PROMO1:[a-z0-9.]+]] = load{{.*}}@__profc_foo{{.*}}3)
60; PROMO-NEXT: {{.*}} = add {{.*}}%[[PROMO1]], %[[MERGE1]]
61; PROMO-NEXT: store{{.*}}@__profc_foo{{.*}}3)
62
63bb15:                                             ; preds = %bb14
64  call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 63969943867, i32 5, i32 4)
65  tail call void @bar(i32 1)
66  ret void
67}
68
69declare void @bar(i32) local_unnamed_addr
70
71; Function Attrs: nounwind
72declare void @llvm.instrprof.increment(i8*, i64, i32, i32) #0
73
74attributes #0 = { nounwind }
75