aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-31 00:33:20 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-31 00:33:20 +0000
commiteb6437a9b23b3d98a4590ba5557111e14eba2edf (patch)
tree5c4af2318e49243b9d21dbcd5b7c59854276b77f /lib/CodeGen/CodeGenFunction.cpp
parent4b76b4fa1a0225bb4113eb67c5dcdbe74a87ec6b (diff)
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
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp8
1 files changed, 7 insertions, 1 deletions
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);