]> granicus.if.org Git - clang/commitdiff
When possible, don't emit the cleanup block. Instead, just move the instructions...
authorAnders Carlsson <andersca@mac.com>
Sun, 31 May 2009 00:33:20 +0000 (00:33 +0000)
committerAnders Carlsson <andersca@mac.com>
Sun, 31 May 2009 00:33:20 +0000 (00:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72654 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenFunction.cpp

index 1a95e6191573e88b8a9398363cf5f11f17eea75a..672f6da502b184e0a2201740bd70757ec83819be 100644 (file)
@@ -652,7 +652,13 @@ void CodeGenFunction::EmitCleanupBlock()
 {
   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);