79 lines · plain
1; RUN: opt < %s --passes=pgo-instr-gen,instrprof --do-counter-promotion=true --sampled-instrumentation=true --skip-ret-exit-block=0 -S | FileCheck --check-prefixes=SAMPLING,PROMO %s2 3; SAMPLING: $__llvm_profile_sampling = comdat any4; SAMPLING: @__llvm_profile_sampling = thread_local global i16 0, comdat5 6define void @foo(i32 %n, i32 %N) {7; SAMPLING-LABEL: @foo8; SAMPLING: %[[VV0:[0-9]+]] = load i16, ptr @__llvm_profile_sampling, align 29; SAMPLING: %[[VV1:[0-9]+]] = icmp ule i16 %[[VV0]], 19910; SAMPLING: br i1 %[[VV1]], label {{.*}}, label {{.*}}, !prof !011; SAMPLING: {{.*}} = load {{.*}} @__profc_foo{{.*}} 3)12; SAMPLING-NEXT: add13; SAMPLING-NEXT: store {{.*}}@__profc_foo{{.*}}3)14bb:15 %tmp = add nsw i32 %n, 116 %tmp1 = add nsw i32 %n, -117 br label %bb218 19bb2:20; PROMO: phi {{.*}}21; PROMO-NEXT: phi {{.*}}22; PROMO-NEXT: phi {{.*}}23; PROMO-NEXT: phi {{.*}}24 %i.0 = phi i32 [ 0, %bb ], [ %tmp10, %bb9 ]25 %tmp3 = icmp slt i32 %i.0, %tmp26 br i1 %tmp3, label %bb4, label %bb527 28bb4:29 tail call void @bar(i32 1)30 br label %bb931 32bb5:33 %tmp6 = icmp slt i32 %i.0, %tmp134 br i1 %tmp6, label %bb7, label %bb835 36bb7:37 tail call void @bar(i32 2)38 br label %bb939 40bb8:41 tail call void @bar(i32 3)42 br label %bb943 44bb9:45; SAMPLING: phi {{.*}}46; SAMPLING-NEXT: %[[V1:[0-9]+]] = add i16 {{.*}}, 147; SAMPLING-NEXT: store i16 %[[V1]], ptr @__llvm_profile_sampling, align 248; SAMPLING: phi {{.*}}49; SAMPLING-NEXT: %[[V2:[0-9]+]] = add i16 {{.*}}, 150; SAMPLING-NEXT: store i16 %[[V2]], ptr @__llvm_profile_sampling, align 251; SAMPLING: phi {{.*}}52; SAMPLING-NEXT: %[[V3:[0-9]+]] = add i16 {{.*}}, 153; SAMPLING-NEXT: store i16 %[[V3]], ptr @__llvm_profile_sampling, align 254; PROMO: %[[LIVEOUT3:[a-z0-9]+]] = phi {{.*}}55; PROMO-NEXT: %[[LIVEOUT2:[a-z0-9]+]] = phi {{.*}}56; PROMO-NEXT: %[[LIVEOUT1:[a-z0-9]+]] = phi {{.*}}57 %tmp10 = add nsw i32 %i.0, 158 %tmp11 = icmp slt i32 %tmp10, %N59 br i1 %tmp11, label %bb2, label %bb1260 61bb12:62 ret void63; PROMO: %[[CHECK1:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}}64; PROMO-NEXT: add {{.*}} %[[CHECK1]], %[[LIVEOUT1]]65; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}66; PROMO-NEXT: %[[CHECK2:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 1)67; PROMO-NEXT: add {{.*}} %[[CHECK2]], %[[LIVEOUT2]]68; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1)69; PROMO-NEXT: %[[CHECK3:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 2)70; PROMO-NEXT: add {{.*}} %[[CHECK3]], %[[LIVEOUT3]]71; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2)72; PROMO-NOT: @__profc_foo{{.*}})73 74}75 76declare void @bar(i32)77 78; SAMPLING: !0 = !{!"branch_weights", i32 200, i32 65336}79