xref: /llvm-project/llvm/test/Transforms/PGOProfile/branch2.ll (revision 443e2a10f69caeedb9fa621366b16fe0d4358279)
150da55a5SRong Xu; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=false -S | FileCheck %s --check-prefixes=GEN,NOTENTRY
2cee313d2SEric Christopher; RUN: llvm-profdata merge %S/Inputs/branch2.proftext -o %t.profdata
350da55a5SRong Xu; RUN: opt < %s -passes=pgo-instr-use -pgo-instrument-entry=false -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
450da55a5SRong Xu
550da55a5SRong Xu; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry=true  -S | FileCheck %s --check-prefixes=GEN,ENTRY
650da55a5SRong Xu; RUN: llvm-profdata merge %S/Inputs/branch2_entry.proftext -o %t.profdata
750da55a5SRong Xu; RUN: opt < %s -passes=pgo-instr-use  -pgo-instrument-entry=true -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
87b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
9cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
10cee313d2SEric Christopher
11cee313d2SEric Christopher; GEN: $__llvm_profile_raw_version = comdat any
12*443e2a10SAlex Brachet; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
13cee313d2SEric Christopher; GEN: @__profn_test_br_2 = private constant [9 x i8] c"test_br_2"
14cee313d2SEric Christopher
15cee313d2SEric Christopherdefine i32 @test_br_2(i32 %i) {
16cee313d2SEric Christopherentry:
17cee313d2SEric Christopher; GEN: entry:
1850da55a5SRong Xu; NOTENTRY-NOT: llvm.instrprof.increment
1941d5033eSNikita Popov; ENTRY: call void @llvm.instrprof.increment(ptr @__profn_test_br_2, i64 {{[0-9]+}}, i32 2, i32 0)
20cee313d2SEric Christopher  %cmp = icmp sgt i32 %i, 0
21cee313d2SEric Christopher  br i1 %cmp, label %if.then, label %if.else
22cee313d2SEric Christopher; USE: br i1 %cmp, label %if.then, label %if.else
23cee313d2SEric Christopher; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
245c31b8b9SArthur Eubanks; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 1, i32 1}
25cee313d2SEric Christopher
26cee313d2SEric Christopherif.then:
27cee313d2SEric Christopher; GEN: if.then:
2841d5033eSNikita Popov; NOTENTRY: call void @llvm.instrprof.increment(ptr @__profn_test_br_2, i64 {{[0-9]+}}, i32 2, i32 0)
2950da55a5SRong Xu; ENTRY-NOT: llvm.instrprof.increment
30cee313d2SEric Christopher  %add = add nsw i32 %i, 2
31cee313d2SEric Christopher  br label %if.end
32cee313d2SEric Christopher
33cee313d2SEric Christopherif.else:
34cee313d2SEric Christopher; GEN: if.else:
3541d5033eSNikita Popov; GEN: call void @llvm.instrprof.increment(ptr @__profn_test_br_2, i64 {{[0-9]+}}, i32 2, i32 1)
36cee313d2SEric Christopher  %sub = sub nsw i32 %i, 2
37cee313d2SEric Christopher  br label %if.end
38cee313d2SEric Christopher
39cee313d2SEric Christopherif.end:
40cee313d2SEric Christopher; GEN: if.end:
41cee313d2SEric Christopher; GEN-NOT: llvm.instrprof.increment
42cee313d2SEric Christopher  %retv = phi i32 [ %add, %if.then ], [ %sub, %if.else ]
43cee313d2SEric Christopher  ret i32 %retv
44cee313d2SEric Christopher; GEN: ret
45cee313d2SEric Christopher}
46