[PATCH] D119553: [AlwaysInliner] Respect noinline call site attribute
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 11 09:02:53 PST 2022
xbolva00 created this revision.
xbolva00 added a reviewer: aeubanks.
Herald added subscribers: ormris, hiraditya.
xbolva00 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
always_inline foo() { }
bar () {
noinline foo();
}
We should prefer call site attribute over attribute on decl. This is fix for AlwaysInliner, similar fix is needed for normal Inliner (follow up).
Related to https://reviews.llvm.org/D119061
https://reviews.llvm.org/D119553
Files:
llvm/lib/Transforms/IPO/AlwaysInliner.cpp
llvm/test/Transforms/Inline/always-inline.ll
Index: llvm/test/Transforms/Inline/always-inline.ll
===================================================================
--- llvm/test/Transforms/Inline/always-inline.ll
+++ llvm/test/Transforms/Inline/always-inline.ll
@@ -314,3 +314,42 @@
call void @inner14()
ret void
}
+
+define internal i32 @inner15() {
+; CHECK: @inner15(
+ ret i32 1
+}
+
+define i32 @outer15() {
+; CHECK-LABEL: @outer15(
+; CHECK: call
+
+ %r = call i32 @inner15() noinline
+ ret i32 %r
+}
+
+define internal i32 @inner16() alwaysinline {
+; CHECK: @inner16(
+ ret i32 1
+}
+
+define i32 @outer16() {
+; CHECK-LABEL: @outer16(
+; CHECK: call
+
+ %r = call i32 @inner16() noinline
+ ret i32 %r
+}
+
+define i32 @inner17() alwaysinline {
+; CHECK: @inner17(
+ ret i32 1
+}
+
+define i32 @outer17() {
+; CHECK-LABEL: @outer17(
+; CHECK: call
+
+ %r = call i32 @inner17() noinline
+ ret i32 %r
+}
Index: llvm/lib/Transforms/IPO/AlwaysInliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -59,7 +59,7 @@
for (User *U : F.users())
if (auto *CB = dyn_cast<CallBase>(U))
- if (CB->getCalledFunction() == &F &&
+ if (CB->getCalledFunction() == &F && !CB->isNoInline() &&
CB->hasFnAttr(Attribute::AlwaysInline))
Calls.insert(CB);
@@ -207,6 +207,9 @@
if (Callee->isDeclaration())
return InlineCost::getNever("no definition");
+ if (CB.isNoInline())
+ return InlineCost::getNever("noinline call site attribute");
+
if (!CB.hasFnAttr(Attribute::AlwaysInline))
return InlineCost::getNever("no alwaysinline attribute");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119553.407902.patch
Type: text/x-patch
Size: 1712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220211/c2c60668/attachment.bin>
More information about the llvm-commits
mailing list