[PATCH] Check the alwaysinline attribute on the call as well as on the caller.

Peter Collingbourne peter at pcc.me.uk
Fri May 16 23:16:31 PDT 2014


http://reviews.llvm.org/D3815

Files:
  lib/Analysis/IPA/InlineCost.cpp
  lib/Transforms/IPO/InlineAlways.cpp
  test/Transforms/Inline/always-inline.ll

Index: lib/Analysis/IPA/InlineCost.cpp
===================================================================
--- lib/Analysis/IPA/InlineCost.cpp
+++ 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: lib/Transforms/IPO/InlineAlways.cpp
===================================================================
--- lib/Transforms/IPO/InlineAlways.cpp
+++ 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: test/Transforms/Inline/always-inline.ll
===================================================================
--- test/Transforms/Inline/always-inline.ll
+++ 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.9505.patch
Type: text/x-patch
Size: 1569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140517/0f9595a7/attachment.bin>


More information about the llvm-commits mailing list