• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -pgo-instr-gen -S | FileCheck %s --check-prefix=GEN
2; RUN: llvm-profdata merge %S/Inputs/branch1.proftext -o %t.profdata
3; RUN: opt < %s -pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
4target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5target triple = "x86_64-unknown-linux-gnu"
6
7; GEN: @__profn_test_br_1 = private constant [9 x i8] c"test_br_1"
8
9define i32 @test_br_1(i32 %i) {
10entry:
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.end
15; USE: br i1 %cmp, label %if.then, label %if.end
16; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
17; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 2, i32 1}
18
19if.then:
20; GEN: if.then:
21; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_1, i32 0, i32 0), i64 25571299074, i32 2, i32 1)
22  %add = add nsw i32 %i, 2
23  br label %if.end
24
25if.end:
26; GEN: if.end:
27; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__profn_test_br_1, i32 0, i32 0), i64 25571299074, i32 2, i32 0)
28  %retv = phi i32 [ %add, %if.then ], [ %i, %entry ]
29  ret i32 %retv
30}
31