[cfe-commits] r82508 - in /cfe/trunk/lib/CodeGen: CGBlocks.cpp CGBlocks.h CGDebugInfo.cpp CGDecl.cpp
Devang Patel
devang.patel at gmail.com
Wed Sep 23 17:49:24 PDT 2009
On Mon, Sep 21, 2009 at 7:12 PM, Mike Stump <mrs at apple.com> wrote:
> Author: mrs
> Date: Mon Sep 21 21:12:52 2009
> New Revision: 82508
>
> URL: http://llvm.org/viewvc/llvm-project?rev=82508&view=rev
> Log:
> Improve debug info generation for __block variables.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBlocks.cpp
> cfe/trunk/lib/CodeGen/CGBlocks.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/CodeGen/CGDecl.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=82508&r1=82507&r2=82508&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Mon Sep 21 21:12:52 2009
> @@ -218,9 +218,12 @@
>
> llvm::Value* Addr = Builder.CreateStructGEP(V, i+5, "tmp");
> NoteForHelper[helpersize].index = i+5;
> - NoteForHelper[helpersize].RequiresCopying = BlockRequiresCopying(VD->getType());
> + NoteForHelper[helpersize].RequiresCopying
> + = BlockRequiresCopying(VD->getType());
> NoteForHelper[helpersize].flag
> - = VD->getType()->isBlockPointerType() ? BLOCK_FIELD_IS_BLOCK : BLOCK_FIELD_IS_OBJECT;
> + = (VD->getType()->isBlockPointerType()
> + ? BLOCK_FIELD_IS_BLOCK
> + : BLOCK_FIELD_IS_OBJECT);
>
> if (LocalDeclMap[VD]) {
> if (BDRE->isByRef()) {
> @@ -386,6 +389,10 @@
> return GenericExtendedBlockLiteralType;
> }
>
> +bool BlockFunction::BlockRequiresCopying(QualType Ty) {
> + return CGM.BlockRequiresCopying(Ty);
> +}
> +
> RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
> const BlockPointerType *BPT =
> E->getCallee()->getType()->getAs<BlockPointerType>();
>
> Modified: cfe/trunk/lib/CodeGen/CGBlocks.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.h?rev=82508&r1=82507&r2=82508&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGBlocks.h (original)
> +++ cfe/trunk/lib/CodeGen/CGBlocks.h Mon Sep 21 21:12:52 2009
> @@ -115,6 +115,16 @@
> PtrToInt8Ty = llvm::PointerType::getUnqual(
> llvm::Type::getInt8Ty(M.getContext()));
> }
> +
> + bool BlockRequiresCopying(QualType Ty) {
> + if (Ty->isBlockPointerType())
> + return true;
> + if (getContext().isObjCNSObjectType(Ty))
> + return true;
> + if (Ty->isObjCObjectPointerType())
> + return true;
> + return false;
> + }
> };
>
> class BlockFunction : public BlockBase {
> @@ -219,15 +229,7 @@
> llvm::Value *getBlockObjectDispose();
> void BuildBlockRelease(llvm::Value *DeclPtr, int flag = BLOCK_FIELD_IS_BYREF);
>
> - bool BlockRequiresCopying(QualType Ty) {
> - if (Ty->isBlockPointerType())
> - return true;
> - if (getContext().isObjCNSObjectType(Ty))
> - return true;
> - if (Ty->isObjCObjectPointerType())
> - return true;
> - return false;
> - }
> + bool BlockRequiresCopying(QualType Ty);
> };
>
> } // end namespace CodeGen
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=82508&r1=82507&r2=82508&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 21 21:12:52 2009
> @@ -918,7 +918,139 @@
> return;
>
> llvm::DICompileUnit Unit = getOrCreateCompileUnit(Decl->getLocation());
> - llvm::DIType Ty = getOrCreateType(Decl->getType(), Unit);
> + QualType Type = Decl->getType();
> + llvm::DIType Ty = getOrCreateType(Type, Unit);
> + if (Decl->hasAttr<BlocksAttr>()) {
> + llvm::DICompileUnit DefUnit;
DefUnit is not set anywhere. Please set it appropriately before using it.
> + unsigned Tag = llvm::dwarf::DW_TAG_structure_type;
> +
> + llvm::SmallVector<llvm::DIDescriptor, 5> EltTys;
> +
> + llvm::DIType FieldTy;
> +
> + QualType FType;
> + uint64_t FieldSize, FieldOffset;
> + unsigned FieldAlign;
> +
> + llvm::DIArray Elements;
> + llvm::DIType EltTy;
> +
> + // Build up structure for the byref. See BuildByRefType.
> + FieldOffset = 0;
> + FType = M->getContext().getPointerType(M->getContext().VoidTy);
> + FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
> + FieldSize = M->getContext().getTypeSize(FType);
> + FieldAlign = M->getContext().getTypeAlign(FType);
> + FieldTy = DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_member, Unit,
> + "__isa", DefUnit,
> + 0, FieldSize, FieldAlign,
> + FieldOffset, 0, FieldTy);
> + EltTys.push_back(FieldTy);
> + FieldOffset += FieldSize;
> +
> + FType = M->getContext().getPointerType(M->getContext().VoidTy);
> + FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
> + FieldSize = M->getContext().getTypeSize(FType);
> + FieldAlign = M->getContext().getTypeAlign(FType);
> + FieldTy = DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_member, Unit,
> + "__forwarding", DefUnit,
> + 0, FieldSize, FieldAlign,
> + FieldOffset, 0, FieldTy);
> + EltTys.push_back(FieldTy);
> + FieldOffset += FieldSize;
This pattern is repeated may times. Please use a helper function that
uses FType and member name.
-
Devang
More information about the cfe-commits
mailing list