Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -S -inline | FileCheck %s |
Chandler Carruth | 625038d | 2016-12-27 07:18:43 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -S -passes='cgscc(inline)' | FileCheck %s |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 3 | |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 4 | ; 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] | 5 | |
| 6 | define i32 @callee_with_select(i1 %c, i32 %a, i32 %b) { |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 7 | %sel = select i1 %c, i32 %a, i32 %b, !prof !0, !unpredictable !1 |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 8 | ret i32 %sel |
| 9 | } |
| 10 | |
| 11 | define 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 Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 16 | ; 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] | 17 | ; CHECK-NEXT: ret i32 [[SEL]] |
| 18 | } |
| 19 | |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 20 | ; 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] | 21 | |
| 22 | define i32 @callee_with_branch(i1 %c) { |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 23 | br i1 %c, label %if, label %else, !unpredictable !1, !prof !2 |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 24 | if: |
| 25 | ret i32 1 |
| 26 | else: |
| 27 | ret i32 2 |
| 28 | } |
| 29 | |
| 30 | define 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 Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 35 | ; CHECK-NEXT: br i1 %C, label %{{.*}}, label %{{.*}}, !prof !2, !unpredictable !1 |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | !0 = !{!"branch_weights", i32 1, i32 2} |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 39 | !1 = !{} |
| 40 | !2 = !{!"branch_weights", i32 3, i32 4} |
| 41 | |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 42 | ; CHECK: !0 = !{!"branch_weights", i32 1, i32 2} |
Sanjay Patel | fd24fb1 | 2016-03-16 18:15:34 +0000 | [diff] [blame] | 43 | ; CHECK: !1 = !{} |
| 44 | ; CHECK: !2 = !{!"branch_weights", i32 3, i32 4} |
Sanjay Patel | ee52b6e | 2016-03-14 20:18:59 +0000 | [diff] [blame] | 45 | |