Author: adrian Date: Mon Jul 6 19:49:35 2015 New Revision: 241534 URL: http://llvm.org/viewvc/llvm-project?rev=241534&view=rev Log: Debug info: Emit distinct __block_literal_generic types for blocks with different function signatures. (Previously clang would emit all block pointer types with the type of the first block pointer in the compile unit.)
rdar://problem/21602473 Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/test/CodeGen/debug-info-block.c Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=241534&r1=241533&r2=241534&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 6 19:49:35 2015 @@ -705,9 +705,6 @@ llvm::DIType *CGDebugInfo::getOrCreateSt llvm::DIType *CGDebugInfo::CreateType(const BlockPointerType *Ty, llvm::DIFile *Unit) { - if (BlockLiteralGeneric) - return BlockLiteralGeneric; - SmallVector<llvm::Metadata *, 8> EltTys; QualType FType; uint64_t FieldSize, FieldOffset; @@ -753,12 +750,15 @@ llvm::DIType *CGDebugInfo::CreateType(co FieldOffset += FieldSize; Elements = DBuilder.getOrCreateArray(EltTys); + // The __block_literal_generic structs are marked with a special + // DW_AT_APPLE_BLOCK attribute and are an implementation detail only + // the debugger needs to know about. To allow type uniquing, emit + // them without a name or a location. EltTy = - DBuilder.createStructType(Unit, "__block_literal_generic", nullptr, LineNo, + DBuilder.createStructType(Unit, "", nullptr, LineNo, FieldOffset, 0, Flags, nullptr, Elements); - BlockLiteralGeneric = DBuilder.createPointerType(EltTy, Size); - return BlockLiteralGeneric; + return DBuilder.createPointerType(EltTy, Size); } llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=241534&r1=241533&r2=241534&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Jul 6 19:49:35 2015 @@ -65,7 +65,6 @@ class CGDebugInfo { llvm::DIType *OCLImage2dArrayDITy = nullptr; llvm::DIType *OCLImage3dDITy = nullptr; llvm::DIType *OCLEventDITy = nullptr; - llvm::DIType *BlockLiteralGeneric = nullptr; /// \brief Cache of previously constructed Types. llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache; Modified: cfe/trunk/test/CodeGen/debug-info-block.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-block.c?rev=241534&r1=241533&r2=241534&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/debug-info-block.c (original) +++ cfe/trunk/test/CodeGen/debug-info-block.c Mon Jul 6 19:49:35 2015 @@ -2,11 +2,28 @@ // Verify that the desired debugging type is generated for a structure // member that is a pointer to a block. -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_generic" -// CHECK-NOT: line +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, scope +// CHECK-NOT: line +// CHECK-SAME: elements: ![[ELEMS1:.*]]) +// CHECK: ![[ELEMS1]] = {{.*, .*, .*,}} ![[FPEL1:.*]], {{.*}} +// CHECK: ![[INT:.*]] = !DIBasicType(name: "int" +// CHECK: ![[FPEL1]] = {{.*}}"__FuncPtr", {{.*}}, baseType: ![[FPTY1:[0-9]+]] +// CHECK: ![[FPTY1]] = {{.*}}baseType: ![[FNTY1:[0-9]+]] +// CHECK: ![[FNTY1]] = !DISubroutineType(types: ![[VOIDVOID:[0-9]+]]) +// CHECK: ![[VOIDVOID]] = !{null, null} // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "__block_descriptor" -// CHECK-NOT: line +// CHECK-NOT: line +// CHECK-SAME: ) + +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, scope +// CHECK-NOT: line +// CHECK-SAME: elements: ![[ELEMS2:.*]]) +// CHECK: ![[ELEMS2]] = {{.*,.*,.*}}, ![[FPEL2:.*]], {{.*}} +// CHECK: ![[FPEL2]] = {{.*}}"__FuncPtr", {{.*}}, baseType: ![[FPTY2:[0-9]+]] +// CHECK: ![[FPTY2]] = {{.*}}baseType: ![[FNTY2:[0-9]+]] +// CHECK: ![[FNTY2]] = !DISubroutineType(types: ![[INTINT:[0-9]+]]) +// CHECK: ![[INTINT]] = !{![[INT]], ![[INT]]} struct inStruct { - void (^genericBlockPtr)(); + void (^voidBlockPtr)(); + int (^intBlockPtr)(int); } is; - _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits