1 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN 2 ; RUN: llvm-profdata merge %S/Inputs/loop1.proftext -o %t.profdata 3 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE 4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 5 target triple = "x86_64-unknown-linux-gnu" 6 7 ; GEN: @__profn_test_simple_for = private constant [15 x i8] c"test_simple_for" 8 9 define i32 @test_simple_for(i32 %n) { 10 entry: 11 ; GEN: entry: 12 ; GEN-NOT: call void @llvm.instrprof.increment 13 br label %for.cond 14 15 for.cond: 16 ; GEN: for.cond: 17 ; GEN-NOT: call void @llvm.instrprof.increment 18 %i = phi i32 [ 0, %entry ], [ %inc1, %for.inc ] 19 %sum = phi i32 [ 1, %entry ], [ %inc, %for.inc ] 20 %cmp = icmp slt i32 %i, %n 21 br i1 %cmp, label %for.body, label %for.end 22 ; USE: br i1 %cmp, label %for.body, label %for.end 23 ; USE-SAME: !prof ![[BW_FOR_COND:[0-9]+]] 24 ; USE: ![[BW_FOR_COND]] = !{!"branch_weights", i32 96, i32 4} 25 26 for.body: 27 ; GEN: for.body: 28 ; GEN-NOT: call void @llvm.instrprof.increment 29 %inc = add nsw i32 %sum, 1 30 br label %for.inc 31 32 for.inc: 33 ; GEN: for.inc: 34 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 0) 35 %inc1 = add nsw i32 %i, 1 36 br label %for.cond 37 38 for.end: 39 ; GEN: for.end: 40 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @__profn_test_simple_for, i32 0, i32 0), i64 34137660316, i32 2, i32 1) 41 ret i32 %sum 42 } 43