aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-02-08 22:13:37 +0000
committerAnders Carlsson <andersca@mac.com>2009-02-08 22:13:37 +0000
commit46831a93e1805ddaebd68f37cdb5496a86b44cf0 (patch)
tree5dc0995e240ef6da4e8d9e891b56a1ef4f1651ce
parent225b16dbaaca36aae6934fafd0ab718393f97019 (diff)
Misc fixes to the cleanup stack code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64096 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index b62499d3ad..4ae8708054 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -586,7 +586,11 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
llvm::SwitchInst *SI = Builder.CreateSwitch(DestCode, EndBlock,
BranchFixups.size());
- Builder.SetInsertPoint(CurBB);
+ // Restore the current basic block (if any)
+ if (CurBB)
+ Builder.SetInsertPoint(CurBB);
+ else
+ Builder.ClearInsertionPoint();
for (size_t i = 0, e = BranchFixups.size(); i != e; ++i) {
llvm::BranchInst *BI = BranchFixups[i];
@@ -658,8 +662,13 @@ void CodeGenFunction::AddBranchFixup(llvm::BranchInst *BI)
void CodeGenFunction::EmitBranchThroughCleanup(llvm::BasicBlock *Dest)
{
+ if (!HaveInsertPoint())
+ return;
+
llvm::BranchInst* BI = Builder.CreateBr(Dest);
+ Builder.ClearInsertionPoint();
+
// The stack is empty, no need to do any cleanup.
if (CleanupEntries.empty())
return;