[cfe-commits] r64161 - /cfe/trunk/lib/CodeGen/CGDecl.cpp

Anders Carlsson andersca at mac.com
Mon Feb 9 12:41:50 PST 2009


Author: andersca
Date: Mon Feb  9 14:41:50 2009
New Revision: 64161

URL: http://llvm.org/viewvc/llvm-project?rev=64161&view=rev
Log:
Use the new cleanup infrastructure for VLAs. The next iteration of patches will remove the old Obj-C EH cleanup code.

Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=64161&r1=64160&r2=64161&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon Feb  9 14:41:50 2009
@@ -178,7 +178,7 @@
     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 @@
       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 =





More information about the cfe-commits mailing list