Check the alwaysinline attribute on the call as well as on the caller.
authorPeter Collingbourne <peter@pcc.me.uk>
Mon, 19 May 2014 18:25:54 +0000 (18:25 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Mon, 19 May 2014 18:25:54 +0000 (18:25 +0000)
Differential Revision: http://reviews.llvm.org/D3815

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209150 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 358f61fd5231480323fc82662e519b98efcad554..66f3f8e02528df1159483b885c159b2abd45e557 100644 (file)
@@ -1259,7 +1259,7 @@ InlineCost InlineCostAnalysis::getInlineCost(CallSite CS, Function *Callee,
 
   // Calls to functions with always-inline attributes should be inlined
   // whenever possible.
 
   // 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();
     if (isInlineViable(*Callee))
       return llvm::InlineCost::getAlways();
     return llvm::InlineCost::getNever();
index c5d9546ccef4306166d246b8255d9232c88c80e3..624cb90c0d5cf53479c86f07e47d0f73fe55d8b3 100644 (file)
@@ -95,8 +95,7 @@ InlineCost AlwaysInliner::getInlineCost(CallSite CS) {
   // that are viable for inlining. FIXME: We shouldn't even get here for
   // declarations.
   if (Callee && !Callee->isDeclaration() &&
   // 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();
 
       ICA->isInlineViable(*Callee))
     return InlineCost::getAlways();
 
index a8703b8987779a68d0ff3e0116360e560ff4b9d6..5ad1bde3e2d21b7ec65332ba0e4ed948eaede89a 100644 (file)
@@ -122,3 +122,14 @@ entry:
   ret void
 }
 
   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
+}