summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-11-13 01:24:05 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-11-13 01:24:05 +0000
commitfcac22eac1a39b72d6aca219036f178adcb19f5d (patch)
tree100222675eb3193978c5788c0af911d71f1fe97c
parentd0e32791d5c54b29bb9479f9cc329ba4ddc6ae7b (diff)
downloadbcm5719-llvm-fcac22eac1a39b72d6aca219036f178adcb19f5d.tar.gz
bcm5719-llvm-fcac22eac1a39b72d6aca219036f178adcb19f5d.zip
Add IsFinished arg to EmitBlock.
- Indicates that caller is done with the block and it can be dropped if it has no predecessors. Useful for callers who need to make landing pads but which may not be reached. No functionality change. llvm-svn: 59207
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp8
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h7
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index a66b6fec041..ad081c91f7c 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -157,9 +157,15 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
return EmitAnyExpr(cast<Expr>(LastStmt), AggLoc);
}
-void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB) {
+void CodeGenFunction::EmitBlock(llvm::BasicBlock *BB, bool IsFinished) {
// Fall out of the current block (if necessary).
EmitBranch(BB);
+
+ if (IsFinished && BB->use_empty()) {
+ delete BB;
+ return;
+ }
+
CurFn->getBasicBlockList().push_back(BB);
Builder.SetInsertPoint(BB);
}
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 21d8f4f6ed2..50b35bd8cdb 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -237,7 +237,12 @@ public:
/// insert point, adding a fall-through branch from the current
/// insert block if necessary. It is legal to call this function
/// even if there is no current insertion point.
- void EmitBlock(llvm::BasicBlock *BB);
+ ///
+ /// IsFinished - If true, indicates that the caller has finished
+ /// emitting branches to the given block and does not expect to emit
+ /// code into it. This means the block can be ignored if it is
+ /// unreachable.
+ void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false);
/// EmitBranch - Emit a branch to the specified basic block from the
/// current insert block, taking care to avoid creation of branches
OpenPOWER on IntegriCloud