summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index e41476e6503..2050d12e466 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -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;
}
OpenPOWER on IntegriCloud