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 | d6312bbbbd7739c8bfd8cc1ddad7662b1c6ee158 (patch) | |
tree | 537b7157c9c541f592812566704d12cc0113b2ce /lib/Analysis/IPA | |
parent | 0fa7dc4762d6fe0ab811f86e5d2c87231f2abcfe (diff) | |
download | llvm-d6312bbbbd7739c8bfd8cc1ddad7662b1c6ee158.tar.gz llvm-d6312bbbbd7739c8bfd8cc1ddad7662b1c6ee158.tar.bz2 llvm-d6312bbbbd7739c8bfd8cc1ddad7662b1c6ee158.tar.xz |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/IPA')
-rw-r--r-- | lib/Analysis/IPA/InlineCost.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Analysis/IPA/InlineCost.cpp b/lib/Analysis/IPA/InlineCost.cpp index a803f8c3bf..683637f5b7 100644 --- a/lib/Analysis/IPA/InlineCost.cpp +++ b/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; |