aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2019-02-14 23:35:53 +0000
committerNick Desaulniers <ndesaulniers@google.com>2019-02-14 23:35:53 +0000
commit19e95fe61182945b7b68ad15348f144fb996633f (patch)
tree1391e2fc68384e938ebb91a07a5de706ee3e0ccb /llvm/lib/Analysis/InlineCost.cpp
parent2694810153cf992823eb45253d26b8567424438f (diff)
downloadllvm-19e95fe61182945b7b68ad15348f144fb996633f.zip
llvm-19e95fe61182945b7b68ad15348f144fb996633f.tar.gz
llvm-19e95fe61182945b7b68ad15348f144fb996633f.tar.bz2
[INLINER] allow inlining of address taken blocks
as long as their uses does not contain calls to functions that capture the argument (potentially allowing the blockaddress to "escape" the lifetime of the caller). TODO: - add more tests - fix crash in llvm::updateCGAndAnalysisManagerForFunctionPass when invoking Transforms/Inline/blockaddress.ll llvm-svn: 354079
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 574a1b6..2f5aa4a 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -1832,7 +1832,7 @@ InlineResult CallAnalyzer::analyzeCall(CallSite CS) {
// see an indirect branch that ends up being dead code at a particular call
// site. If the blockaddress escapes the function, e.g., via a global
// variable, inlining may lead to an invalid cross-function reference.
- if (BB->hasAddressTaken())
+ if (BB->hasAddressTaken() && BB->addressPotentiallyEscapesFunction())
return "blockaddress";
// Analyze the cost of this block. If we blow through the threshold, this
@@ -2082,7 +2082,7 @@ InlineResult llvm::isInlineViable(Function &F) {
if (isa<IndirectBrInst>(BI->getTerminator()))
return "contains indirect branches";
- if (BI->hasAddressTaken())
+ if (BI->hasAddressTaken() && BI->addressPotentiallyEscapesFunction())
return "uses block address";
for (auto &II : *BI) {