An alwaysinline function may not get inlined in inliner-wrapper due to
the inlining order.
Previously for the following, the inliner would first inline @a() into @b(),
```
define void @a() {
entry:
call void @b()
ret void
}
define void @b() alwaysinline {
entry:
br label %for.cond
for.cond:
call void @a()
br label %for.cond
}
```
making @b() recursive and unable to be inlined into @a(), ending at
```
define void @a() {
entry:
call void @b()
ret void
}
define void @b() alwaysinline {
entry:
br label %for.cond
for.cond:
call void @b()
br label %for.cond
}
```
Running always-inliner first makes sure that we respect alwaysinline in more cases.
Fixes https://bugs.llvm.org/show_bug.cgi?id=46945.
Reviewed By: davidxl, rnk
Differential Revision: https://reviews.llvm.org/D86988
26 lines
893 B
LLVM
26 lines
893 B
LLVM
; RUN: opt < %s 2>&1 -disable-output \
|
|
; RUN: -passes=inline -print-before-all -print-after-all | FileCheck %s -check-prefix=INL
|
|
; RUN: opt < %s 2>&1 -disable-output \
|
|
; RUN: -passes=inline -print-before-all -print-after-all -print-module-scope | FileCheck %s -check-prefix=INL-MOD
|
|
|
|
; INL: IR Dump Before {{InlinerPass .*scc: .tester, foo}}
|
|
; INL-NOT: IR Dump After {{InlinerPass}}
|
|
; INL: IR Dump Before {{InlinerPass .*scc: .tester}}
|
|
; INL: IR Dump After {{InlinerPass .*scc: .tester}}
|
|
|
|
; INL-MOD: IR Dump Before {{InlinerPass .*scc: .tester, foo}}
|
|
; INL-MOD: IR Dump After {{InlinerPass .*invalidated: .*scc: .tester, foo}}
|
|
; INL-MOD: IR Dump Before {{InlinerPass .*scc: .tester}}
|
|
; INL-MOD: IR Dump After {{InlinerPass .*scc: .tester}}
|
|
|
|
|
|
define void @tester() noinline {
|
|
call void @foo()
|
|
ret void
|
|
}
|
|
|
|
define internal void @foo() alwaysinline {
|
|
call void @tester()
|
|
ret void
|
|
}
|