1 ; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -skip-ret-exit-block=0 -S | FileCheck --check-prefix=PROMO --check-prefix=NONATOMIC_PROMO %s
2 ; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -atomic-counter-update-promoted -skip-ret-exit-block=0 -S | FileCheck --check-prefix=PROMO --check-prefix=ATOMIC_PROMO %s
4 define void @foo(i32 %n, i32 %N) {
6 ; PROMO: {{.*}} = load {{.*}} @__profc_foo{{.*}} 3)
8 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3)
10 %tmp = add nsw i32 %n, 1
11 %tmp1 = add nsw i32 %n, -1
14 bb2: ; preds = %bb9, %bb
16 ; PROMO-NEXT: phi {{.*}}
17 ; PROMO-NEXT: phi {{.*}}
18 ; PROMO-NEXT: phi {{.*}}
19 %i.0 = phi i32 [ 0, %bb ], [ %tmp10, %bb9 ]
20 %tmp3 = icmp slt i32 %i.0, %tmp
21 br i1 %tmp3, label %bb4, label %bb5
24 tail call void @bar(i32 1)
28 %tmp6 = icmp slt i32 %i.0, %tmp1
29 br i1 %tmp6, label %bb7, label %bb8
32 tail call void @bar(i32 2)
36 tail call void @bar(i32 3)
39 bb9: ; preds = %bb8, %bb7, %bb4
40 ; PROMO: %[[LIVEOUT3:[a-z0-9]+]] = phi {{.*}}
41 ; PROMO-NEXT: %[[LIVEOUT2:[a-z0-9]+]] = phi {{.*}}
42 ; PROMO-NEXT: %[[LIVEOUT1:[a-z0-9]+]] = phi {{.*}}
43 %tmp10 = add nsw i32 %i.0, 1
44 %tmp11 = icmp slt i32 %tmp10, %N
45 br i1 %tmp11, label %bb2, label %bb12
49 ; NONATOMIC_PROMO: %[[PROMO1:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}}
50 ; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO1]], %[[LIVEOUT1]]
51 ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}
52 ; NONATOMIC_PROMO-NEXT: %[[PROMO2:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 1)
53 ; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO2]], %[[LIVEOUT2]]
54 ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1)
55 ; NONATOMIC_PROMO-NEXT: %[[PROMO3:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 2)
56 ; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO3]], %[[LIVEOUT3]]
57 ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2)
58 ; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}, i64 %[[LIVEOUT1]] seq_cst
59 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT2]] seq_cst
60 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT3]] seq_cst
61 ; PROMO-NOT: @__profc_foo{{.*}})
66 declare void @bar(i32)