diff options
| author | Gerolf Hoflehner <ghoflehner@apple.com> | 2014-04-17 00:21:52 +0000 |
|---|---|---|
| committer | Gerolf Hoflehner <ghoflehner@apple.com> | 2014-04-17 00:21:52 +0000 |
| commit | 5f6268a40ee3e17bbec910329f5b4e8eb940069f (patch) | |
| tree | eec583a2ed9fe2a6cbe6d0a9c03892e3f7dddafc /llvm/lib/Analysis/IPA/InlineCost.cpp | |
| parent | d0848a6fa8bb4ef5d9187c66dddc82bc610cbb79 (diff) | |
| download | bcm5719-llvm-5f6268a40ee3e17bbec910329f5b4e8eb940069f.tar.gz bcm5719-llvm-5f6268a40ee3e17bbec910329f5b4e8eb940069f.zip | |
Inline a function when the always_inline attribute
is set even when it contains a indirect branch.
The attribute overrules correctness concerns
like the escape of a local block address.
This is for rdar://16501761
llvm-svn: 206429
Diffstat (limited to 'llvm/lib/Analysis/IPA/InlineCost.cpp')
| -rw-r--r-- | llvm/lib/Analysis/IPA/InlineCost.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/IPA/InlineCost.cpp b/llvm/lib/Analysis/IPA/InlineCost.cpp index a803f8c3bf9..683637f5b7f 100644 --- a/llvm/lib/Analysis/IPA/InlineCost.cpp +++ b/llvm/lib/Analysis/IPA/InlineCost.cpp @@ -1300,8 +1300,14 @@ bool InlineCostAnalysis::isInlineViable(Function &F) { F.getAttributes().hasAttribute(AttributeSet::FunctionIndex, Attribute::ReturnsTwice); for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; ++BI) { - // Disallow inlining of functions which contain an indirect branch. - if (isa<IndirectBrInst>(BI->getTerminator())) + // Disallow inlining of functions which contain an indirect branch, + // unless the always_inline attribute is set. + // The attribute serves as a assertion that no local address + // like a block label can escpape the function. + // Revisit enabling inlining for functions with indirect branches + // when a more sophisticated espape/points-to analysis becomes available. + if (isa<IndirectBrInst>(BI->getTerminator()) && + !F.hasFnAttribute(Attribute::AlwaysInline)) return false; for (BasicBlock::iterator II = BI->begin(), IE = BI->end(); II != IE; |

