]> granicus.if.org Git - clang/commitdiff
Catch another trivial case where we can avoid emitting a separate return blcok.
authorDaniel Dunbar <daniel@zuster.org>
Sun, 19 Jul 2009 08:24:34 +0000 (08:24 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 19 Jul 2009 08:24:34 +0000 (08:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76365 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenFunction.cpp

index e41476e65033e64247746bb361883cb1c5a81ffb..2050d12e466bbcb1f60ec02a9b3f83527cdb9f9e 100644 (file)
@@ -82,11 +82,12 @@ void CodeGenFunction::EmitReturnBlock() {
   if (CurBB) {
     assert(!CurBB->getTerminator() && "Unexpected terminated block.");
 
-    // We have a valid insert point, reuse it if there are no explicit
-    // jumps to the return block.
-    if (ReturnBlock->use_empty())
+    // We have a valid insert point, reuse it if it is empty or there are no
+    // explicit jumps to the return block.
+    if (CurBB->empty() || ReturnBlock->use_empty()) {
+      ReturnBlock->replaceAllUsesWith(CurBB);
       delete ReturnBlock;
-    else
+    else
       EmitBlock(ReturnBlock);
     return;
   }