From: Anders Carlsson Date: Sun, 31 May 2009 00:33:20 +0000 (+0000) Subject: When possible, don't emit the cleanup block. Instead, just move the instructions... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb6437a9b23b3d98a4590ba5557111e14eba2edf;p=clang When possible, don't emit the cleanup block. Instead, just move the instructions to the current block. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72654 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 1a95e61915..672f6da502 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -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);