aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-03-17 05:53:35 +0000
committerAnders Carlsson <andersca@mac.com>2009-03-17 05:53:35 +0000
commit0ae7b2b2f964bd6145d65ef52dc2a28025b2bd06 (patch)
treea660bcfa23438a39c2736d511427b549e1c3fc2c /lib/CodeGen/CodeGenFunction.cpp
parent4598ffab57ba948a323b0877d3d35b7d71d27a4c (diff)
Initialize the cleanup.dst variable if necessary. Fixes PR3789.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67075 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index a54f9bd235..441c9fcdbf 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -549,7 +549,7 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
EndBlock = createBasicBlock("cleanup.end");
llvm::BasicBlock *CurBB = Builder.GetInsertBlock();
-
+
Builder.SetInsertPoint(SwitchBlock);
llvm::Value *DestCodePtr = CreateTempAlloca(llvm::Type::Int32Ty,
@@ -561,9 +561,14 @@ CodeGenFunction::CleanupBlockInfo CodeGenFunction::PopCleanupBlock()
BranchFixups.size());
// Restore the current basic block (if any)
- if (CurBB)
+ if (CurBB) {
Builder.SetInsertPoint(CurBB);
- else
+
+ // If we had a current basic block, we also need to emit an instruction
+ // to initialize the cleanup destination.
+ Builder.CreateStore(llvm::Constant::getNullValue(llvm::Type::Int32Ty),
+ DestCodePtr);
+ } else
Builder.ClearInsertionPoint();
for (size_t i = 0, e = BranchFixups.size(); i != e; ++i) {