Rework IRgen invariant w.r.t. current insert point.
 - EmitStmt is no longer required to finish with a current insertion
   point defined (i.e. it does not need to make dummy
   blocks). Instead, it can clear the insertion point in the builder
   which indicates that the current insertion point is unreachable.
 - CodeGenFunction provides HaveInsertPoint and EnsureInsertPoint
   which respectively test if there is an insert point and ensure an
   insertion point exists (by making a dummy block).
 - Clearly mark functions in CodeGenFunction which can be called with
   no insertion point defined. Currently this is a limited set, and
   EmitStmt simply EnsureInsertPoint()s before emitting subsequent IR.

Remove EmitDummyBlock, which is no longer needed. Clients who haven't
already cleared the insertion point (typically via EmitBranch) can do
so by hand.

Remove isDummyBlock, which has effectively been renamed to
HaveInsertPoint.

The main thrust of this change is that we no longer have create dummy
blocks just to destroy them a short time later in EmitBlock in the
common case that there is no unreachable code following something like
a goto. 

Additionally, this means that we are not using the hokey condition in
isDummyBlock that a block without a name is a dummy block. Guess how
well that works when we never emit block names!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59089 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 8722e15..70b9b49 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -1621,6 +1621,7 @@
       if (AllMatched) {   
         if (CatchParam) {
           CGF.EmitStmt(CatchParam);
+          assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?");
           CGF.Builder.CreateStore(Caught, CGF.GetAddrOfLocalVar(VD));
         }
         
@@ -1648,6 +1649,7 @@
       // Emit the @catch block.
       CGF.EmitBlock(MatchedBlock);
       CGF.EmitStmt(CatchParam);
+      assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?");
 
       llvm::Value *Tmp = 
         CGF.Builder.CreateBitCast(Caught, CGF.ConvertType(VD->getType()), 
@@ -1717,15 +1719,15 @@
   
   CGF.Builder.CreateCall(ObjCTypes.ExceptionThrowFn, ExceptionAsObject);
   CGF.Builder.CreateUnreachable();
-  CGF.EmitDummyBlock();
+
+  // Clear the insertion point to indicate we are in unreachable code.
+  CGF.Builder.ClearInsertionPoint();
 }
 
 void CodeGenFunction::EmitJumpThroughFinally(ObjCEHEntry *E,
                                              llvm::BasicBlock *Dst,
                                              bool ExecuteTryExit) {
-  llvm::BasicBlock *Src = Builder.GetInsertBlock();
-    
-  if (!Src || isDummyBlock(Src))
+  if (!HaveInsertPoint())
     return;
   
   // Find the destination code for this block. We always use 0 for the
@@ -1746,7 +1748,7 @@
 
   // Set the destination code and branch.
   Builder.CreateStore(ID, E->DestCode);
-  Builder.CreateBr(ExecuteTryExit ? E->FinallyBlock : E->FinallyNoExit);
+  EmitBranch(ExecuteTryExit ? E->FinallyBlock : E->FinallyNoExit);
 }
 
 /* *** Private Interface *** */