]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Transforms/PGOProfile/branch2.ll
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / test / Transforms / PGOProfile / branch2.ll
1 ; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
2 ; RUN: opt < %s -passes=pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
3 ; RUN: llvm-profdata merge %S/Inputs/branch2.proftext -o %t.profdata
4 ; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
5 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
8
9 ; GEN: $__llvm_profile_raw_version = comdat any
10 ; GEN: @__llvm_profile_raw_version = constant i64 {{[0-9]+}}, comdat
11 ; GEN: @__profn_test_br_2 = private constant [9 x i8] c"test_br_2"
12
13 define i32 @test_br_2(i32 %i) {
14 entry:
15 ; GEN: entry:
16 ; GEN-NOT: llvm.instrprof.increment
17   %cmp = icmp sgt i32 %i, 0
18   br i1 %cmp, label %if.then, label %if.else
19 ; USE: br i1 %cmp, label %if.then, label %if.else
20 ; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
21 ; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 1, i32 1}
22
23 if.then:
24 ; GEN: if.then:
25 ; 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)
26   %add = add nsw i32 %i, 2
27   br label %if.end
28
29 if.else:
30 ; GEN: if.else:
31 ; 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)
32   %sub = sub nsw i32 %i, 2
33   br label %if.end
34
35 if.end:
36 ; GEN: if.end:
37 ; GEN-NOT: llvm.instrprof.increment
38   %retv = phi i32 [ %add, %if.then ], [ %sub, %if.else ]
39   ret i32 %retv
40 ; GEN: ret
41 }