Easwaran Raman | ed27975 | 2019-01-09 19:26:17 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -inline -inline-remark-attribute --inline-threshold=0 -S | FileCheck %s |
David Bolvansky | c1b27b5 | 2018-08-28 15:27:25 +0000 | [diff] [blame] | 2 | |
| 3 | ; Test that the inliner adds inline remark attributes to non-inlined callsites. |
| 4 | |
Easwaran Raman | ed27975 | 2019-01-09 19:26:17 +0000 | [diff] [blame^] | 5 | declare void @ext(); |
| 6 | |
David Bolvansky | c1b27b5 | 2018-08-28 15:27:25 +0000 | [diff] [blame] | 7 | define void @foo() { |
| 8 | call void @bar(i1 true) |
| 9 | ret void |
| 10 | } |
| 11 | |
| 12 | define void @bar(i1 %p) { |
| 13 | br i1 %p, label %bb1, label %bb2 |
| 14 | |
| 15 | bb1: |
| 16 | call void @foo() |
Easwaran Raman | ed27975 | 2019-01-09 19:26:17 +0000 | [diff] [blame^] | 17 | call void @ext() |
David Bolvansky | c1b27b5 | 2018-08-28 15:27:25 +0000 | [diff] [blame] | 18 | ret void |
| 19 | |
| 20 | bb2: |
| 21 | call void @bar(i1 true) |
| 22 | ret void |
| 23 | } |
| 24 | |
| 25 | ;; Test 1 - Add different inline remarks to similar callsites. |
| 26 | define void @test1() { |
| 27 | ; CHECK-LABEL: @test1 |
| 28 | ; CHECK-NEXT: call void @bar(i1 true) [[ATTR1:#[0-9]+]] |
| 29 | ; CHECK-NEXT: call void @bar(i1 false) [[ATTR2:#[0-9]+]] |
| 30 | call void @bar(i1 true) |
| 31 | call void @bar(i1 false) |
| 32 | ret void |
| 33 | } |
| 34 | |
| 35 | define void @noop() { |
| 36 | ret void |
| 37 | } |
| 38 | |
| 39 | ;; Test 2 - Printed InlineResult messages are followed by InlineCost. |
| 40 | define void @test2(i8*) { |
| 41 | ; CHECK-LABEL: @test2 |
| 42 | ; CHECK-NEXT: call void @noop() [[ATTR3:#[0-9]+]] [ "CUSTOM_OPERAND_BUNDLE"() ] |
| 43 | ; CHECK-NEXT: ret void |
| 44 | call void @noop() ; extepected to be inlined |
| 45 | call void @noop() [ "CUSTOM_OPERAND_BUNDLE"() ] ; cannot be inlined because of unsupported operand bundle |
| 46 | ret void |
| 47 | } |
| 48 | |
Easwaran Raman | ed27975 | 2019-01-09 19:26:17 +0000 | [diff] [blame^] | 49 | ; CHECK: attributes [[ATTR1]] = { "inline-remark"="(cost=25, threshold=0)" } |
David Bolvansky | c1b27b5 | 2018-08-28 15:27:25 +0000 | [diff] [blame] | 50 | ; CHECK: attributes [[ATTR2]] = { "inline-remark"="(cost=never): recursive" } |
| 51 | ; CHECK: attributes [[ATTR3]] = { "inline-remark"="unsupported operand bundle; (cost={{.*}}, threshold={{.*}})" } |