[PATCH] Check the alwaysinline attribute on the call as well as on the caller.
Peter Collingbourne
peter at pcc.me.uk
Mon May 19 11:33:23 PDT 2014
Closed by commit rL209150 (authored by @pcc).
http://reviews.llvm.org/D3815
Files:
llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
llvm/trunk/test/Transforms/Inline/always-inline.ll
Index: llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
===================================================================
--- llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
+++ llvm/trunk/lib/Analysis/IPA/InlineCost.cpp
@@ -1259,7 +1259,7 @@
// Calls to functions with always-inline attributes should be inlined
// whenever possible.
- if (Callee->hasFnAttribute(Attribute::AlwaysInline)) {
+ if (CS.hasFnAttr(Attribute::AlwaysInline)) {
if (isInlineViable(*Callee))
return llvm::InlineCost::getAlways();
return llvm::InlineCost::getNever();
Index: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
+++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
@@ -95,8 +95,7 @@
// that are viable for inlining. FIXME: We shouldn't even get here for
// declarations.
if (Callee && !Callee->isDeclaration() &&
- Callee->getAttributes().hasAttribute(AttributeSet::FunctionIndex,
- Attribute::AlwaysInline) &&
+ CS.hasFnAttr(Attribute::AlwaysInline) &&
ICA->isInlineViable(*Callee))
return InlineCost::getAlways();
Index: llvm/trunk/test/Transforms/Inline/always-inline.ll
===================================================================
--- llvm/trunk/test/Transforms/Inline/always-inline.ll
+++ llvm/trunk/test/Transforms/Inline/always-inline.ll
@@ -122,3 +122,14 @@
ret void
}
+define i32 @inner7() {
+ ret i32 1
+}
+define i32 @outer7() {
+; CHECK-LABEL: @outer7(
+; CHECK-NOT: call
+; CHECK: ret
+
+ %r = call i32 @inner7() alwaysinline
+ ret i32 %r
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3815.9581.patch
Type: text/x-patch
Size: 1668 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140519/9fb6bb8a/attachment.bin>
More information about the llvm-commits
mailing list