mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
64733b19f6
Summary: Sometimes reading an output *.ll file it is not easy to understand why some callsites are not inlined. We can read output of inline remarks (option --pass-remarks-missed=inline) and try correlating its messages with the callsites. An easier way proposed by this patch is to add to every callsite processed by Inliner an attribute with the latest message that describes the cause of not inlining this callsite. The attribute is called //inline-remark//. By default this feature is off. It can be switched on by the option //-inline-remark-attribute//. For example in the provided test the result method //@test1// has two callsites //@bar// and inline remarks report different inlining missed reasons: remark: <unknown>:0:0: bar not inlined into test1 because too costly to inline (cost=-5, threshold=-6) remark: <unknown>:0:0: bar not inlined into test1 because it should never be inlined (cost=never): recursive It is not clear which remark correspond to which callsite. With the inline remark attribute enabled we get the reasons attached to their callsites: define void @test1() { call void @bar(i1 true) #0 call void @bar(i1 false) #2 ret void } attributes #0 = { "inline-remark"="(cost=-5, threshold=-6)" } .. attributes #2 = { "inline-remark"="(cost=never): recursive" } Patch by: yrouban (Yevgeny Rouban) Reviewers: xbolva00, tejohnson, apilipenko Reviewed By: xbolva00, tejohnson Subscribers: eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D50435 llvm-svn: 340834
49 lines
1.3 KiB
LLVM
49 lines
1.3 KiB
LLVM
; RUN: opt < %s -inline -inline-remark-attribute --inline-threshold=-2 -S | FileCheck %s
|
|
|
|
; Test that the inliner adds inline remark attributes to non-inlined callsites.
|
|
|
|
define void @foo() {
|
|
call void @bar(i1 true)
|
|
ret void
|
|
}
|
|
|
|
define void @bar(i1 %p) {
|
|
br i1 %p, label %bb1, label %bb2
|
|
|
|
bb1:
|
|
call void @foo()
|
|
ret void
|
|
|
|
bb2:
|
|
call void @bar(i1 true)
|
|
ret void
|
|
}
|
|
|
|
;; Test 1 - Add different inline remarks to similar callsites.
|
|
define void @test1() {
|
|
; CHECK-LABEL: @test1
|
|
; CHECK-NEXT: call void @bar(i1 true) [[ATTR1:#[0-9]+]]
|
|
; CHECK-NEXT: call void @bar(i1 false) [[ATTR2:#[0-9]+]]
|
|
call void @bar(i1 true)
|
|
call void @bar(i1 false)
|
|
ret void
|
|
}
|
|
|
|
define void @noop() {
|
|
ret void
|
|
}
|
|
|
|
;; Test 2 - Printed InlineResult messages are followed by InlineCost.
|
|
define void @test2(i8*) {
|
|
; CHECK-LABEL: @test2
|
|
; CHECK-NEXT: call void @noop() [[ATTR3:#[0-9]+]] [ "CUSTOM_OPERAND_BUNDLE"() ]
|
|
; CHECK-NEXT: ret void
|
|
call void @noop() ; extepected to be inlined
|
|
call void @noop() [ "CUSTOM_OPERAND_BUNDLE"() ] ; cannot be inlined because of unsupported operand bundle
|
|
ret void
|
|
}
|
|
|
|
; CHECK: attributes [[ATTR1]] = { "inline-remark"="(cost=-5, threshold=-6)" }
|
|
; CHECK: attributes [[ATTR2]] = { "inline-remark"="(cost=never): recursive" }
|
|
; CHECK: attributes [[ATTR3]] = { "inline-remark"="unsupported operand bundle; (cost={{.*}}, threshold={{.*}})" }
|