[cfe-commits] r59207 - in /cfe/trunk/lib/CodeGen: CGStmt.cpp CodeGenFunction.h
Daniel Dunbar
daniel at zuster.org
Wed Nov 12 17:24:06 PST 2008
Author: ddunbar
Date: Wed Nov 12 19:24:05 2008
New Revision: 59207
URL: http://llvm.org/viewvc/llvm-project?rev=59207&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=59207&r1=59206&r2=59207&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed Nov 12 19:24:05 2008
@@ -157,9 +157,15 @@
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);
}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=59207&r1=59206&r2=59207&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Nov 12 19:24:05 2008
@@ -237,7 +237,12 @@
/// 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
More information about the cfe-commits
mailing list