1; RUN: opt < %s -S -inline | FileCheck %s
2
3; Make sure that profile and unpredictable  metadata is preserved when cloning a select.
4
5define i32 @callee_with_select(i1 %c, i32 %a, i32 %b) {
6  %sel = select i1 %c, i32 %a, i32 %b, !prof !0, !unpredictable !1
7  ret i32 %sel
8}
9
10define i32 @caller_of_select(i1 %C, i32 %A, i32 %B) {
11  %ret = call i32 @callee_with_select(i1 %C, i32 %A, i32 %B)
12  ret i32 %ret
13
14; CHECK-LABEL: @caller_of_select(
15; CHECK-NEXT:  [[SEL:%.*]] = select i1 %C, i32 %A, i32 %B, !prof !0, !unpredictable !1
16; CHECK-NEXT:  ret i32 [[SEL]]
17}
18
19; Make sure that profile and unpredictable metadata is preserved when cloning a branch.
20
21define i32 @callee_with_branch(i1 %c) {
22  br i1 %c, label %if, label %else, !unpredictable !1, !prof !2
23if:
24  ret i32 1
25else:
26  ret i32 2
27}
28
29define i32 @caller_of_branch(i1 %C) {
30  %ret = call i32 @callee_with_branch(i1 %C)
31  ret i32 %ret
32
33; CHECK-LABEL: @caller_of_branch(
34; CHECK-NEXT:  br i1 %C, label %{{.*}}, label %{{.*}}, !prof !2, !unpredictable !1
35}
36
37!0 = !{!"branch_weights", i32 1, i32 2}
38!1 = !{}
39!2 = !{!"branch_weights", i32 3, i32 4}
40
41; CHECK: !0 = !{!"branch_weights", i32 1, i32 2}
42; CHECK: !1 = !{}
43; CHECK: !2 = !{!"branch_weights", i32 3, i32 4}
44
45