aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/BasicBlock.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/IR/BasicBlock.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/IR/BasicBlock.cpp')
-rw-r--r--llvm/lib/IR/BasicBlock.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 18e2fd89..7f2e762 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -442,6 +442,14 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
return New;
}
+bool BasicBlock::addressPotentiallyEscapesFunction() {
+ for (const Use& U : BlockAddress::get(this)->uses())
+ if (const CallInst* CI = dyn_cast<CallInst>(U))
+ if (!CI->paramHasAttr(U.getOperandNo(), Attribute::NoCapture))
+ return true;
+ return false;
+}
+
void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
Instruction *TI = getTerminator();
if (!TI)