Initialize the cleanup.dst variable if necessary. Fixes PR3789.
llvm-svn: 67075
This commit is contained in:
parent
e8911a9a13
commit
e73e3ecc04
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// RUN: clang -emit-llvm %s -o %t &&
|
||||
// RUN: grep "store i32 0, i32* %cleanup" %t | count 2
|
||||
void f(int n) {
|
||||
int a[n];
|
||||
|
||||
{
|
||||
int b[n];
|
||||
|
||||
if (n)
|
||||
return;
|
||||
}
|
||||
|
||||
if (n)
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue