When possible, don't emit the cleanup block. Instead, just move the instructions to the current block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72654 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 1a95e61..672f6da 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -652,7 +652,13 @@
 {
   CleanupBlockInfo Info = PopCleanupBlock();
   
-  EmitBlock(Info.CleanupBlock);
+  llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
+  if (CurBB && !CurBB->getTerminator() && 
+      Info.CleanupBlock->getNumUses() == 0) {
+    CurBB->getInstList().splice(CurBB->end(), Info.CleanupBlock->getInstList());
+    delete Info.CleanupBlock;
+  } else 
+    EmitBlock(Info.CleanupBlock);
   
   if (Info.SwitchBlock)
     EmitBlock(Info.SwitchBlock);