blob: 3c967d6618f780ceef4987294fc168c3ae3d5a3d [file] [log] [blame]
Sanjay Patelee52b6e2016-03-14 20:18:59 +00001; RUN: opt < %s -S -inline | FileCheck %s
Chandler Carruth625038d2016-12-27 07:18:43 +00002; RUN: opt < %s -S -passes='cgscc(inline)' | FileCheck %s
Sanjay Patelee52b6e2016-03-14 20:18:59 +00003
Sanjay Patelfd24fb12016-03-16 18:15:34 +00004; Make sure that profile and unpredictable metadata is preserved when cloning a select.
Sanjay Patelee52b6e2016-03-14 20:18:59 +00005
6define i32 @callee_with_select(i1 %c, i32 %a, i32 %b) {
Sanjay Patelfd24fb12016-03-16 18:15:34 +00007 %sel = select i1 %c, i32 %a, i32 %b, !prof !0, !unpredictable !1
Sanjay Patelee52b6e2016-03-14 20:18:59 +00008 ret i32 %sel
9}
10
11define i32 @caller_of_select(i1 %C, i32 %A, i32 %B) {
12 %ret = call i32 @callee_with_select(i1 %C, i32 %A, i32 %B)
13 ret i32 %ret
14
15; CHECK-LABEL: @caller_of_select(
Sanjay Patelfd24fb12016-03-16 18:15:34 +000016; CHECK-NEXT: [[SEL:%.*]] = select i1 %C, i32 %A, i32 %B, !prof !0, !unpredictable !1
Sanjay Patelee52b6e2016-03-14 20:18:59 +000017; CHECK-NEXT: ret i32 [[SEL]]
18}
19
Sanjay Patelfd24fb12016-03-16 18:15:34 +000020; Make sure that profile and unpredictable metadata is preserved when cloning a branch.
Sanjay Patelee52b6e2016-03-14 20:18:59 +000021
22define i32 @callee_with_branch(i1 %c) {
Sanjay Patelfd24fb12016-03-16 18:15:34 +000023 br i1 %c, label %if, label %else, !unpredictable !1, !prof !2
Sanjay Patelee52b6e2016-03-14 20:18:59 +000024if:
25 ret i32 1
26else:
27 ret i32 2
28}
29
30define i32 @caller_of_branch(i1 %C) {
31 %ret = call i32 @callee_with_branch(i1 %C)
32 ret i32 %ret
33
34; CHECK-LABEL: @caller_of_branch(
Sanjay Patelfd24fb12016-03-16 18:15:34 +000035; CHECK-NEXT: br i1 %C, label %{{.*}}, label %{{.*}}, !prof !2, !unpredictable !1
Sanjay Patelee52b6e2016-03-14 20:18:59 +000036}
37
38!0 = !{!"branch_weights", i32 1, i32 2}
Sanjay Patelfd24fb12016-03-16 18:15:34 +000039!1 = !{}
40!2 = !{!"branch_weights", i32 3, i32 4}
41
Sanjay Patelee52b6e2016-03-14 20:18:59 +000042; CHECK: !0 = !{!"branch_weights", i32 1, i32 2}
Sanjay Patelfd24fb12016-03-16 18:15:34 +000043; CHECK: !1 = !{}
44; CHECK: !2 = !{!"branch_weights", i32 3, i32 4}
Sanjay Patelee52b6e2016-03-14 20:18:59 +000045