[cfe-commits] r63038 - /cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Daniel Dunbar daniel at zuster.org
Mon Jan 26 13:25:21 PST 2009


Author: ddunbar
Date: Mon Jan 26 15:25:20 2009
New Revision: 63038

URL: http://llvm.org/viewvc/llvm-project?rev=63038&view=rev
Log:
Skip emission of final return block if possible (e.g., functions with
a unified return).

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=63038&r1=63037&r2=63038&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Jan 26 15:25:20 2009
@@ -77,9 +77,13 @@
   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()) {





More information about the cfe-commits mailing list