Debug Info: Use identifier to reference DIType in containing type field of

a DISubprogram.
    
Verifier is updated accordingly.

llvm-svn: 190229
This commit is contained in:
Manman Ren 2013-09-07 00:04:05 +00:00
parent c11e303acd
commit efdb887d1f
5 changed files with 8 additions and 6 deletions

View File

@ -426,8 +426,8 @@ namespace llvm {
unsigned getVirtuality() const { return getUnsignedField(10); } unsigned getVirtuality() const { return getUnsignedField(10); }
unsigned getVirtualIndex() const { return getUnsignedField(11); } unsigned getVirtualIndex() const { return getUnsignedField(11); }
DICompositeType getContainingType() const { DITypeRef getContainingType() const {
return getFieldAs<DICompositeType>(12); return getFieldAs<DITypeRef>(12);
} }
unsigned getFlags() const { unsigned getFlags() const {

View File

@ -1289,7 +1289,7 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
addUInt(Block, 0, dwarf::DW_FORM_udata, SP.getVirtualIndex()); addUInt(Block, 0, dwarf::DW_FORM_udata, SP.getVirtualIndex());
addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, 0, Block); addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, 0, Block);
ContainingTypeMap.insert(std::make_pair(SPDie, ContainingTypeMap.insert(std::make_pair(SPDie,
SP.getContainingType())); DD->resolve(SP.getContainingType())));
} }
if (!SP.isDefinition()) { if (!SP.isDefinition()) {

View File

@ -1125,7 +1125,7 @@ DISubprogram DIBuilder::createMethod(DIDescriptor Context,
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK), ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK),
ConstantInt::get(Type::getInt32Ty(VMContext), VIndex), ConstantInt::get(Type::getInt32Ty(VMContext), VIndex),
VTableHolder, VTableHolder.generateRef(),
ConstantInt::get(Type::getInt32Ty(VMContext), Flags), ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized), ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
Fn, Fn,

View File

@ -524,7 +524,7 @@ bool DISubprogram::Verify() const {
if (!fieldIsMDNode(DbgNode, 7)) if (!fieldIsMDNode(DbgNode, 7))
return false; return false;
// Containing type @ field 12. // Containing type @ field 12.
if (!fieldIsMDNode(DbgNode, 12)) if (!fieldIsTypeRef(DbgNode, 12))
return false; return false;
return DbgNode->getNumOperands() == 20; return DbgNode->getNumOperands() == 20;
} }

View File

@ -4,6 +4,8 @@
; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s ; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
; CHECK: [[TYPE:.*]]: DW_TAG_structure_type ; CHECK: [[TYPE:.*]]: DW_TAG_structure_type
; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]}) ; CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]})
; CHECK: [[SP:.*]]: DW_TAG_subprogram
; CHECK: DW_AT_containing_type [DW_FORM_ref4] (cu + {{.*}} => {[[TYPE]]})
; IR generated from clang -g with the following source: ; IR generated from clang -g with the following source:
; struct C { ; struct C {
; virtual void foo(); ; virtual void foo();
@ -50,7 +52,7 @@ attributes #1 = { nounwind readnone }
!10 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !11, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !10 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !11, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!11 = metadata !{metadata !12} !11 = metadata !{metadata !12}
!12 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] !12 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
!13 = metadata !{i32 786478, metadata !1, metadata !4, metadata !"foo", metadata !"foo", metadata !"_ZN1C3fooEv", i32 2, metadata !14, i1 false, i1 false, i32 1, i32 0, metadata !4, i32 256, i1 false, null, null, i32 0, metadata !17, i32 2} ; [ DW_TAG_subprogram ] [line 2] [foo] !13 = metadata !{i32 786478, metadata !1, metadata !4, metadata !"foo", metadata !"foo", metadata !"_ZN1C3fooEv", i32 2, metadata !14, i1 false, i1 false, i32 1, i32 0, metadata !"_ZTS1C", i32 256, i1 false, null, null, i32 0, metadata !17, i32 2} ; [ DW_TAG_subprogram ] [line 2] [foo]
!14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] !14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
!15 = metadata !{null, metadata !16} !15 = metadata !{null, metadata !16}
!16 = metadata !{i32 786447, i32 0, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !4} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from C] !16 = metadata !{i32 786447, i32 0, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !4} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from C]