From eb6437a9b23b3d98a4590ba5557111e14eba2edf Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 31 May 2009 00:33:20 +0000 Subject: [PATCH] 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 --- lib/CodeGen/CodeGenFunction.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); -- 2.40.0