diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2014-05-19 18:25:54 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2014-05-19 18:25:54 +0000 |
commit | 68a889757dec7f4b6d7e2e87863f3152bb0603c3 (patch) | |
tree | 97731338e18963b8eed6d1576829f4b4270637ad | |
parent | 230c5eb4bde7314331ae5c0bca65087ed504202c (diff) | |
download | bcm5719-llvm-68a889757dec7f4b6d7e2e87863f3152bb0603c3.tar.gz bcm5719-llvm-68a889757dec7f4b6d7e2e87863f3152bb0603c3.zip |
Check the alwaysinline attribute on the call as well as on the caller.
Differential Revision: http://reviews.llvm.org/D3815
llvm-svn: 209150
-rw-r--r-- | llvm/lib/Analysis/IPA/InlineCost.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/InlineAlways.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Transforms/Inline/always-inline.ll | 11 |
3 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/IPA/InlineCost.cpp b/llvm/lib/Analysis/IPA/InlineCost.cpp index 358f61fd523..66f3f8e0252 100644 --- a/llvm/lib/Analysis/IPA/InlineCost.cpp +++ b/llvm/lib/Analysis/IPA/InlineCost.cpp @@ -1259,7 +1259,7 @@ InlineCost InlineCostAnalysis::getInlineCost(CallSite CS, Function *Callee, // 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(); diff --git a/llvm/lib/Transforms/IPO/InlineAlways.cpp b/llvm/lib/Transforms/IPO/InlineAlways.cpp index c5d9546ccef..624cb90c0d5 100644 --- a/llvm/lib/Transforms/IPO/InlineAlways.cpp +++ b/llvm/lib/Transforms/IPO/InlineAlways.cpp @@ -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() && - Callee->getAttributes().hasAttribute(AttributeSet::FunctionIndex, - Attribute::AlwaysInline) && + CS.hasFnAttr(Attribute::AlwaysInline) && ICA->isInlineViable(*Callee)) return InlineCost::getAlways(); diff --git a/llvm/test/Transforms/Inline/always-inline.ll b/llvm/test/Transforms/Inline/always-inline.ll index a8703b89877..5ad1bde3e2d 100644 --- a/llvm/test/Transforms/Inline/always-inline.ll +++ b/llvm/test/Transforms/Inline/always-inline.ll @@ -122,3 +122,14 @@ entry: 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 +} |