From cbc2bcaf17c40bf316c62c7d9853b103a02b4613 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Fri, 5 Jun 2009 23:26:36 +0000 Subject: As an optimization, we maintain a cache of generated ___Block_byref_id_object_dispose and ___Block_byref_id_object_copy functions so that we can simply reuse instead of creating a new one. Additionally, add an assert to ensure no one yet tries to align a __block variable beyond the alignment of a pointer as the codegen is incomplete. llvm-svn: 72974 --- clang/lib/CodeGen/CGBlocks.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CGBlocks.h') diff --git a/clang/lib/CodeGen/CGBlocks.h b/clang/lib/CodeGen/CGBlocks.h index 56d3a2d3b10..5d46ac78f69 100644 --- a/clang/lib/CodeGen/CGBlocks.h +++ b/clang/lib/CodeGen/CGBlocks.h @@ -98,6 +98,9 @@ public: llvm::Value *BlockObjectDispose; const llvm::Type *PtrToInt8Ty; + std::map AssignCache; + std::map DestroyCache; + BlockModule(ASTContext &C, llvm::Module &M, const llvm::TargetData &TD, CodeGenTypes &T, CodeGenModule &CodeGen) : Context(C), TheModule(M), TheTargetData(TD), Types(T), @@ -131,8 +134,9 @@ public: variable */ BLOCK_FIELD_IS_WEAK = 16, /* declared __weak, only used in byref copy helpers */ - BLOCK_BYREF_CALLER = 128 /* called from __block (byref) copy/dispose + BLOCK_BYREF_CALLER = 128, /* called from __block (byref) copy/dispose support routines */ + BLOCK_BYREF_CURRENT_MAX = 256 }; /// BlockInfo - Information to generate a block literal. @@ -199,8 +203,10 @@ public: llvm::Constant *GeneratebyrefCopyHelperFunction(const llvm::Type *, int flag); llvm::Constant *GeneratebyrefDestroyHelperFunction(const llvm::Type *T, int); - llvm::Constant *BuildbyrefCopyHelper(const llvm::Type *T, int flag); - llvm::Constant *BuildbyrefDestroyHelper(const llvm::Type *T, int flag); + llvm::Constant *BuildbyrefCopyHelper(const llvm::Type *T, int flag, + unsigned Align); + llvm::Constant *BuildbyrefDestroyHelper(const llvm::Type *T, int flag, + unsigned Align); llvm::Value *getBlockObjectAssign(); llvm::Value *getBlockObjectDispose(); -- cgit v1.2.3