aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-01-26 21:25:20 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-01-26 21:25:20 +0000
commitd7d6e6abff8cb25d8b1223fbc8865f8f2ff795e3 (patch)
tree728522642300ca0bfec8fe626b72a02fc69f2bb2 /lib/CodeGen/CodeGenFunction.cpp
parente7689886d6a68507ae90ca330bd24bf89d4d6df1 (diff)
Skip emission of final return block if possible (e.g., functions with
a unified return). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 2fd8d638d6..b509843daa 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -77,9 +77,13 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
assert(BreakContinueStack.empty() &&
"mismatched push/pop in break/continue stack!");
- // Emit function epilog (to return). This has the nice side effect
- // of also automatically handling code that falls off the end.
- EmitBlock(ReturnBlock);
+ // Emit function epilog (to return). For cleanliness, skip emission
+ // if we know it is safe (when it is unused and the current block is
+ // unterminated).
+ if (!ReturnBlock->use_empty() ||
+ !Builder.GetInsertBlock() ||
+ Builder.GetInsertBlock()->getTerminator())
+ EmitBlock(ReturnBlock);
// Emit debug descriptor for function end.
if (CGDebugInfo *DI = CGM.getDebugInfo()) {