xref: /llvm-project/llvm/test/Transforms/PGOProfile/branch1.ll (revision 443e2a10f69caeedb9fa621366b16fe0d4358279)
1cee313d2SEric Christopher; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN --check-prefix=GEN-COMDAT
2cee313d2SEric Christopher; RUN: opt < %s -mtriple=x86_64-apple-darwin -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN --check-prefix=GEN-DARWIN-LINKONCE
3cee313d2SEric Christopher
4cee313d2SEric Christopher; RUN: llvm-profdata merge %S/Inputs/branch1.proftext -o %t.profdata
5cee313d2SEric Christopher; RUN: llvm-profdata merge %S/Inputs/branch1_large_count.proftext -o %t.l.profdata
6cee313d2SEric Christopher
7cee313d2SEric Christopher; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
8cee313d2SEric Christopher; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.l.profdata -S | FileCheck %s --check-prefix=USE-LARGE
9cee313d2SEric Christopher
10cee313d2SEric Christopher; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pass-remarks=pgo-instrumentation -pgo-emit-branch-prob -S 2>&1| FileCheck %s --check-prefix=ANALYSIS
11cee313d2SEric Christopher
127b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
13cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
14cee313d2SEric Christopher; GEN-DARWIN-LINKONCE: target triple = "x86_64-apple-darwin"
15cee313d2SEric Christopher
16cee313d2SEric Christopher; GEN-COMDAT: $__llvm_profile_raw_version = comdat any
17*443e2a10SAlex Brachet; GEN-COMDAT: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat
18cee313d2SEric Christopher; GEN-LINKONCE: @__llvm_profile_raw_version = linkonce constant i64 {{[0-9]+}}
19cee313d2SEric Christopher; GEN: @__profn_test_br_1 = private constant [9 x i8] c"test_br_1"
20cee313d2SEric Christopher
21cee313d2SEric Christopherdefine i32 @test_br_1(i32 %i) {
22cee313d2SEric Christopher; USE-LABEL: @test_br_1
23cee313d2SEric Christopher; USE-SAME: !prof ![[FUNC_ENTRY_COUNT:[0-9]+]]
24cee313d2SEric Christopherentry:
25cee313d2SEric Christopher; GEN: entry:
2641d5033eSNikita Popov; GEN: call void @llvm.instrprof.increment(ptr @__profn_test_br_1, i64 {{[0-9]+}}, i32 2, i32 0)
27cee313d2SEric Christopher  %cmp = icmp sgt i32 %i, 0
28cee313d2SEric Christopher  br i1 %cmp, label %if.then, label %if.end
29cee313d2SEric Christopher; USE: br i1 %cmp, label %if.then, label %if.end
30cee313d2SEric Christopher; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
315c31b8b9SArthur Eubanks; USE-DAG: ![[BW_ENTRY]] = !{!"branch_weights", i32 2, i32 1}
32cee313d2SEric Christopher; USE-LARGE: br i1 %cmp, label %if.then, label %if.end
33cee313d2SEric Christopher; USE-LARGE-SAME: !prof ![[BW_L_ENTRY:[0-9]+]]
345c31b8b9SArthur Eubanks; USE-LARGE-DAG: ![[BW_L_ENTRY]] = !{!"branch_weights", i32 -1431655766, i32 1431655765}
35cee313d2SEric Christopher
36cee313d2SEric Christopherif.then:
37cee313d2SEric Christopher; GEN: if.then:
3841d5033eSNikita Popov; GEN: call void @llvm.instrprof.increment(ptr @__profn_test_br_1, i64 {{[0-9]+}}, i32 2, i32 1)
39cee313d2SEric Christopher  %add = add nsw i32 %i, 2
40cee313d2SEric Christopher  br label %if.end
41cee313d2SEric Christopher
42cee313d2SEric Christopherif.end:
43cee313d2SEric Christopher; GEN: if.end:
44cee313d2SEric Christopher; GEN-NOT: llvm.instrprof.increment
45cee313d2SEric Christopher; GEN: ret i32
46cee313d2SEric Christopher  %retv = phi i32 [ %add, %if.then ], [ %i, %entry ]
47cee313d2SEric Christopher  ret i32 %retv
48cee313d2SEric Christopher}
49cee313d2SEric Christopher; USE-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}}
50cee313d2SEric Christopher; USE-DAG: {{![0-9]+}} = !{!"DetailedSummary", {{![0-9]+}}}
51cee313d2SEric Christopher; USE-DAG: ![[FUNC_ENTRY_COUNT]] = !{!"function_entry_count", i64 3}
52cee313d2SEric Christopher
53cee313d2SEric Christopher; ANALYSIS:remark: <unknown>:0:0: sgt_i32_Zero {{.*}}66.67% (total count : 3)
54