Home | History | Annotate | Download | only in PGOProfile
      1 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
      2 ; RUN: llvm-profdata merge %S/Inputs/branch2.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_br_2 = private constant [9 x i8] c"test_br_2"
      8 
      9 define i32 @test_br_2(i32 %i) {
     10 entry:
     11 ; GEN: entry:
     12 ; GEN-NOT: llvm.instrprof.increment
     13   %cmp = icmp sgt i32 %i, 0
     14   br i1 %cmp, label %if.then, label %if.else
     15 ; USE: br i1 %cmp, label %if.then, label %if.else
     16 ; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
     17 ; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 1, i32 1}
     18 
     19 if.then:
     20 ; GEN: if.then:
     21 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 29667547796, i32 2, i32 0)
     22   %add = add nsw i32 %i, 2
     23   br label %if.end
     24 
     25 if.else:
     26 ; GEN: if.else:
     27 ; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_2, i32 0, i32 0), i64 29667547796, i32 2, i32 1)
     28   %sub = sub nsw i32 %i, 2
     29   br label %if.end
     30 
     31 if.end:
     32 ; GEN: if.end:
     33 ; GEN-NOT: llvm.instrprof.increment
     34   %retv = phi i32 [ %add, %if.then ], [ %sub, %if.else ]
     35   ret i32 %retv
     36 ; GEN: ret
     37 }
     38