From 6b5a61b6dc400027fd793dcadceeb9da944a37ea Mon Sep 17 00:00:00 2001 From: John McCall Date: Mon, 7 Feb 2011 10:33:21 +0000 Subject: A few more tweaks to the blocks AST representation: - BlockDeclRefExprs always store VarDecls - BDREs no longer store copy expressions - BlockDecls now store a list of captured variables, information about how they're captured, and a copy expression if necessary With that in hand, change IR generation to use the captures data in blocks instead of walking the block independently. Additionally, optimize block layout by emitting fields in descending alignment order, with a heuristic for filling in words when alignment of the end of the block header is insufficient for the most aligned field. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125005 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDecl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/CodeGen/CGDecl.cpp') diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 65ddfa6051..0f74a3f530 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -328,7 +328,7 @@ llvm::Value *CodeGenFunction::BuildBlockByrefAddress(llvm::Value *BaseAddr, /// T x; /// } x /// -const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) { +const llvm::Type *CodeGenFunction::BuildByRefType(const VarDecl *D) { std::pair &Info = ByRefValueInfo[D]; if (Info.first) return Info.first; @@ -353,7 +353,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) { // int32_t __size; Types.push_back(Int32Ty); - bool HasCopyAndDispose = BlockRequiresCopying(Ty); + bool HasCopyAndDispose = getContext().BlockRequiresCopying(Ty); if (HasCopyAndDispose) { /// void *__copy_helper; Types.push_back(Int8PtrTy); @@ -507,7 +507,7 @@ namespace { void Emit(CodeGenFunction &CGF, bool IsForEH) { llvm::Value *V = CGF.Builder.CreateStructGEP(Addr, 1, "forwarding"); V = CGF.Builder.CreateLoad(V); - CGF.BuildBlockRelease(V); + CGF.BuildBlockRelease(V, BlockFunction::BLOCK_FIELD_IS_BYREF); } }; } @@ -788,7 +788,6 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D, Builder.CreateStore(V, size_field); if (flags & BLOCK_HAS_COPY_DISPOSE) { - SynthesizeCopyDisposeHelpers = true; llvm::Value *copy_helper = Builder.CreateStructGEP(DeclPtr, 4); Builder.CreateStore(BuildbyrefCopyHelper(DeclPtr->getType(), flag, Align.getQuantity(), &D), -- cgit v1.2.3-18-g5258