1; RUN: opt < %s -pgo-instr-gen -instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s 2; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s 3 4@g = common local_unnamed_addr global i32 0, align 4 5 6define void @foo(i32 %arg) local_unnamed_addr { 7; PROMO-LABEL: @foo 8bb: 9 %tmp = add nsw i32 %arg, -1 10 br label %bb1 11bb1: ; preds = %bb11, %bb 12 %tmp2 = phi i32 [ 0, %bb ], [ %tmp12, %bb11 ] 13 %tmp3 = icmp sgt i32 %tmp2, %arg 14 br i1 %tmp3, label %bb7, label %bb4 15 16bb4: ; preds = %bb1 17 tail call void @bar(i32 1) 18 %tmp5 = load i32, i32* @g, align 4 19 %tmp6 = icmp sgt i32 %tmp5, 100 20 br i1 %tmp6, label %bb15_0, label %bb11 21 22bb7: ; preds = %bb1 23 %tmp8 = icmp slt i32 %tmp2, %tmp 24 br i1 %tmp8, label %bb9, label %bb10 25 26bb9: ; preds = %bb7 27 tail call void @bar(i32 2) 28 br label %bb11 29 30bb10: ; preds = %bb7 31 tail call void @bar(i32 3) 32 br label %bb11 33 34bb11: ; preds = %bb10, %bb9, %bb4 35 %tmp12 = add nuw nsw i32 %tmp2, 1 36 %tmp13 = icmp slt i32 %tmp2, 99 37 br i1 %tmp13, label %bb1, label %bb14 38 39bb14: ; preds = %bb11 40; PROMO-LABEL: bb14: 41 tail call void @bar(i32 0) 42 br label %bb15 43; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 0) 44; PROMO-NEXT: add 45; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0) 46; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1) 47; PROMO-NEXT: add 48; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1) 49; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 2) 50; PROMO-NEXT: add 51; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2) 52; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 3) 53; PROMO-NEXT: add 54; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3) 55 56 57bb15_0: ; preds = %bb11 58; PROMO-LABEL: bb15_0: 59 br label %bb15 60; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 0) 61; PROMO-NEXT: add 62; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0) 63; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1) 64; PROMO-NEXT: add 65; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1) 66; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 2) 67; PROMO-NEXT: add 68; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2) 69; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4) 70; PROMO-NEXT: add 71; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}4) 72; PROMO-NOT: @__profc_foo 73 74 75bb15: ; preds = %bb14, %bb4 76 tail call void @bar(i32 1) 77 ret void 78} 79 80declare void @bar(i32) local_unnamed_addr 81