summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-02-09 20:41:50 +0000
committerAnders Carlsson <andersca@mac.com>2009-02-09 20:41:50 +0000
commit15949b3a32a9607df92278508c330052b1b12542 (patch)
tree073c082ea8e73e90c9db9de19570d78a107a8d1b /clang/lib
parentbfee7e921b66b82e37a924d9cc6ab58a1a6baad5 (diff)
downloadbcm5719-llvm-15949b3a32a9607df92278508c330052b1b12542.tar.gz
bcm5719-llvm-15949b3a32a9607df92278508c330052b1b12542.zip
Use the new cleanup infrastructure for VLAs. The next iteration of patches will remove the old Obj-C EH cleanup code.
llvm-svn: 64161
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index eba4d319efc..ce76ed56bbf 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/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 =
OpenPOWER on IntegriCloud