[llvm-branch-commits] [cfe-branch] r121544 - in /cfe/branches/Apple/whitney/lib/CodeGen: CGBlocks.cpp CGBlocks.h CGDecl.cpp

Daniel Dunbar daniel at zuster.org
Fri Dec 10 13:37:13 PST 2010


Author: ddunbar
Date: Fri Dec 10 15:37:13 2010
New Revision: 121544

URL: http://llvm.org/viewvc/llvm-project?rev=121544&view=rev
Log:
Merge r119174:
--
Author: Fariborz Jahanian <fjahanian at apple.com>
Date:   Mon Nov 15 19:19:38 2010 +0000

    Some cleanup of block API code.

Modified:
    cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp
    cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h
    cfe/branches/Apple/whitney/lib/CodeGen/CGDecl.cpp

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp?rev=121544&r1=121543&r2=121544&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.cpp Fri Dec 10 15:37:13 2010
@@ -39,7 +39,6 @@
                          const llvm::StructType* Ty,
                          llvm::Constant *BlockVarLayout,
                          std::vector<HelperInfo> *NoteForHelper) {
-  bool BlockHasCopyDispose = Info.BlockHasCopyDispose;
   CharUnits Size = Info.BlockSize;
   const llvm::Type *UnsignedLongTy
     = CGM.getTypes().ConvertType(getContext().UnsignedLongTy);
@@ -58,7 +57,7 @@
   Elts.push_back(C);
 
   // optional copy/dispose helpers
-  if (BlockHasCopyDispose) {
+  if (Info.BlockHasCopyDispose) {
     // copy_func_helper_decl
     Elts.push_back(BuildCopyHelper(Ty, NoteForHelper));
 
@@ -218,7 +217,7 @@
       = CodeGenFunction(CGM).GenerateBlockFunction(CurGD, BE, Info, CurFuncDecl,
                                                    BlockVarLayout,
                                                    LocalDeclMap);
-    BlockHasCopyDispose |= Info.BlockHasCopyDispose;
+    SynthesizeCopyDisposeHelpers |= Info.BlockHasCopyDispose;
     Elts[3] = Fn;
 
     // FIXME: Don't use BlockHasCopyDispose, it is set more often then
@@ -569,10 +568,9 @@
     return;
 
   // Don't run the expensive check, unless we have to.
-  if (!BlockHasCopyDispose)
-    if (E->isByRef()
-        || BlockRequiresCopying(E))
-      BlockHasCopyDispose = true;
+  if (!SynthesizeCopyDisposeHelpers)
+    if (E->isByRef() || BlockRequiresCopying(E))
+      SynthesizeCopyDisposeHelpers = true;
 
   const ValueDecl *D = cast<ValueDecl>(E->getDecl());
 
@@ -605,7 +603,7 @@
     const llvm::Type *PtrStructTy
       = llvm::PointerType::get(BuildByRefType(VD), 0);
     // The block literal will need a copy/destroy helper.
-    BlockHasCopyDispose = true;
+    SynthesizeCopyDisposeHelpers = true;
     
     const llvm::Type *Ty = PtrStructTy;
     Ty = llvm::PointerType::get(Ty, 0);
@@ -776,8 +774,9 @@
   else
     BlockVarLayout = llvm::Constant::getNullValue(PtrToInt8Ty);
   
-  QualType ParmTy = getContext().getBlockParmType(BlockHasCopyDispose,
-                                                  BlockLayout);
+  QualType ParmTy = getContext().getBlockParmType(
+                                        SynthesizeCopyDisposeHelpers,
+                                        BlockLayout);
 
   // FIXME: This leaks
   ImplicitParamDecl *SelfDecl =
@@ -907,7 +906,7 @@
   Info.BlockSize = BlockOffset;
   Info.BlockAlign = BlockAlign;
   Info.BlockLayout = BlockLayout;
-  Info.BlockHasCopyDispose = BlockHasCopyDispose;
+  Info.BlockHasCopyDispose = SynthesizeCopyDisposeHelpers;
   return Fn;
 }
 
@@ -942,7 +941,7 @@
 }
 
 llvm::Constant *BlockFunction::
-GenerateCopyHelperFunction(bool BlockHasCopyDispose, const llvm::StructType *T,
+GenerateCopyHelperFunction(const llvm::StructType *T,
                            std::vector<HelperInfo> *NoteForHelperp) {
   QualType R = getContext().VoidTy;
 
@@ -1031,8 +1030,7 @@
 }
 
 llvm::Constant *BlockFunction::
-GenerateDestroyHelperFunction(bool BlockHasCopyDispose,
-                              const llvm::StructType* T,
+GenerateDestroyHelperFunction(const llvm::StructType* T,
                               std::vector<HelperInfo> *NoteForHelperp) {
   QualType R = getContext().VoidTy;
 
@@ -1112,14 +1110,12 @@
 
 llvm::Constant *BlockFunction::BuildCopyHelper(const llvm::StructType *T,
                                        std::vector<HelperInfo> *NoteForHelper) {
-  return CodeGenFunction(CGM).GenerateCopyHelperFunction(BlockHasCopyDispose,
-                                                         T, NoteForHelper);
+  return CodeGenFunction(CGM).GenerateCopyHelperFunction(T, NoteForHelper);
 }
 
 llvm::Constant *BlockFunction::BuildDestroyHelper(const llvm::StructType *T,
                                       std::vector<HelperInfo> *NoteForHelperp) {
-  return CodeGenFunction(CGM).GenerateDestroyHelperFunction(BlockHasCopyDispose,
-                                                            T, NoteForHelperp);
+  return CodeGenFunction(CGM).GenerateDestroyHelperFunction(T, NoteForHelperp);
 }
 
 llvm::Constant *BlockFunction::
@@ -1293,5 +1289,5 @@
   PtrToInt8Ty = llvm::PointerType::getUnqual(
             llvm::Type::getInt8Ty(VMContext));
 
-  BlockHasCopyDispose = false;
+  SynthesizeCopyDisposeHelpers = false;
 }

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h?rev=121544&r1=121543&r2=121544&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGBlocks.h Fri Dec 10 15:37:13 2010
@@ -154,8 +154,8 @@
   /// for a value with the given size and alignment requirements.
   CharUnits getBlockOffset(CharUnits Size, CharUnits Align);
 
-  /// BlockHasCopyDispose - True iff the block uses copy/dispose.
-  bool BlockHasCopyDispose;
+  /// SynthesizeCopyDisposeHelpers - True iff the block uses copy/dispose.
+  bool SynthesizeCopyDisposeHelpers;
 
   /// BlockLayout - The layout of the block's storage, represented as
   /// a sequence of expressions which require such storage.  The
@@ -179,9 +179,9 @@
   ImplicitParamDecl *BlockStructDecl;
   ImplicitParamDecl *getBlockStructDecl() { return BlockStructDecl; }
 
-  llvm::Constant *GenerateCopyHelperFunction(bool, const llvm::StructType *,
+  llvm::Constant *GenerateCopyHelperFunction(const llvm::StructType *,
                                              std::vector<HelperInfo> *);
-  llvm::Constant *GenerateDestroyHelperFunction(bool, const llvm::StructType *,
+  llvm::Constant *GenerateDestroyHelperFunction(const llvm::StructType *,
                                                 std::vector<HelperInfo> *);
 
   llvm::Constant *BuildCopyHelper(const llvm::StructType *,

Modified: cfe/branches/Apple/whitney/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/CodeGen/CGDecl.cpp?rev=121544&r1=121543&r2=121544&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/branches/Apple/whitney/lib/CodeGen/CGDecl.cpp Fri Dec 10 15:37:13 2010
@@ -697,7 +697,7 @@
     Builder.CreateStore(V, size_field);
 
     if (flags & BLOCK_HAS_COPY_DISPOSE) {
-      BlockHasCopyDispose = true;
+      SynthesizeCopyDisposeHelpers = true;
       llvm::Value *copy_helper = Builder.CreateStructGEP(DeclPtr, 4);
       Builder.CreateStore(BuildbyrefCopyHelper(DeclPtr->getType(), flag, 
                                                Align.getQuantity()),





More information about the llvm-branch-commits mailing list