xref: /llvm-project/llvm/test/Transforms/PGOProfile/noreturncall.ll (revision b5d884a38c3524fdba82c525f2cd0237e85c60ee)
1; RUN: llvm-profdata merge %S/Inputs/noreturncall.proftext -o %t.profdata
2; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=USE
3; REQUIRES: asserts
4
5target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8declare i32 @bar0(i32)
9
10define i32 @bar2(i32 %i) {
11entry:
12  unreachable
13}
14
15define i32 @foo(i32 %i, i32 %j, i32 %k) {
16entry:
17  %cmp = icmp slt i32 %i, 999
18  br i1 %cmp, label %if.then, label %if.end
19; USE: br i1 %cmp, label %if.then, label %if.end
20; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]
21
22if.then:
23  %call = call i32 @bar0(i32 %i)
24  br label %if.end
25
26if.end:
27  %ret.0 = phi i32 [ %call, %if.then ], [ 0, %entry ]
28  %cmp1 = icmp sgt i32 %j, 1000
29  %cmp3 = icmp sgt i32 %k, 99
30  %or.cond = and i1 %cmp1, %cmp3
31  br i1 %or.cond, label %if.then4, label %if.end7
32; USE: br i1 %or.cond, label %if.then4, label %if.end7
33; USE-SAME: !prof ![[BW_IF:[0-9]+]]
34
35if.then4:
36  %call5 = call i32 @bar2(i32 undef)
37  br label %if.end7
38
39if.end7:
40  %mul = mul nsw i32 %ret.0, %ret.0
41  ret i32 %mul
42}
43; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 21, i32 0}
44; USE: ![[BW_IF]] = !{!"branch_weights", i32 0, i32 21}
45