]> granicus.if.org Git - clang/commitdiff
Add IsFinished arg to EmitBlock.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 13 Nov 2008 01:24:05 +0000 (01:24 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 13 Nov 2008 01:24:05 +0000 (01:24 +0000)
 - 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59207 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.h

index a66b6fec04186ea24129cb899c5d17bc6bad08bd..ad081c91f7c4b0719086d81421d9621558aef2d1 100644 (file)
@@ -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);
 }
index 21d8f4f6ed235f2090c213bfd8ae7f4a977a94de..50b35bd8cdbc971286cb40064f9cea7296b44e5d 100644 (file)
@@ -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