diff options
author | Anders Carlsson <andersca@mac.com> | 2009-02-09 20:41:50 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-02-09 20:41:50 +0000 |
commit | 5ecb1b9377a6408486df5a10538bdc932706e053 (patch) | |
tree | fd1d52f8632f67589621f46c22bb10df28962453 /lib/CodeGen/CGDecl.cpp | |
parent | f3a79a96eecff0fba4de8e29831a5ec0eaf90385 (diff) |
Use the new cleanup infrastructure for VLAs. The next iteration of patches will remove the old Obj-C EH cleanup code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64161 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index eba4d319ef..ce76ed56bb 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -178,7 +178,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { if (Ty->isVariablyModifiedType()) EmitVLASize(Ty); } else { - if (!StackSaveValues.back()) { + if (!DidCallStackSave) { // Save the stack. const llvm::Type *LTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); llvm::Value *Stack = CreateTempAlloca(LTy, "saved_stack"); @@ -187,9 +187,19 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { llvm::Value *V = Builder.CreateCall(F); Builder.CreateStore(V, Stack); + + DidCallStackSave = true; + + { + // Push a cleanup block and restore the stack there. + CleanupScope scope(*this); - StackSaveValues.back() = StackDepth = Stack; + V = Builder.CreateLoad(Stack, "tmp"); + llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::stackrestore); + Builder.CreateCall(F, V); + } } + // Get the element type. const llvm::Type *LElemTy = ConvertType(Ty); const llvm::Type *LElemPtrTy = |