Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -S -inline | FileCheck %s |
| 2 | |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 3 | ; Make sure that profile and unpredictable metadata is preserved when cloning a select. |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 4 | |
| 5 | define i32 @callee_with_select(i1 %c, i32 %a, i32 %b) { |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 6 | %sel = select i1 %c, i32 %a, i32 %b, !prof !0, !unpredictable !1 |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 7 | ret i32 %sel |
| 8 | } |
| 9 | |
| 10 | define 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( |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 15 | ; CHECK-NEXT: [[SEL:%.*]] = select i1 %C, i32 %A, i32 %B, !prof !0, !unpredictable !1 |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 16 | ; CHECK-NEXT: ret i32 [[SEL]] |
| 17 | } |
| 18 | |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 19 | ; Make sure that profile and unpredictable metadata is preserved when cloning a branch. |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 20 | |
| 21 | define i32 @callee_with_branch(i1 %c) { |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 22 | br i1 %c, label %if, label %else, !unpredictable !1, !prof !2 |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 23 | if: |
| 24 | ret i32 1 |
| 25 | else: |
| 26 | ret i32 2 |
| 27 | } |
| 28 | |
| 29 | define 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( |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 34 | ; CHECK-NEXT: br i1 %C, label %{{.*}}, label %{{.*}}, !prof !2, !unpredictable !1 |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | !0 = !{!"branch_weights", i32 1, i32 2} |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 38 | !1 = !{} |
| 39 | !2 = !{!"branch_weights", i32 3, i32 4} |
| 40 | |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 41 | ; CHECK: !0 = !{!"branch_weights", i32 1, i32 2} |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame^] | 42 | ; CHECK: !1 = !{} |
| 43 | ; CHECK: !2 = !{!"branch_weights", i32 3, i32 4} |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 44 | |