[llvm] r271680 - [codeview] Add basic record type translation
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 08:58:25 PDT 2016
Author: rnk
Date: Fri Jun 3 10:58:20 2016
New Revision: 271680
URL: http://llvm.org/viewvc/llvm-project?rev=271680&view=rev
Log:
[codeview] Add basic record type translation
This only translates data members for now. Translating overloaded
methods is complicated, so I stopped short of doing that.
Reviewers: aaboud
Differential Revision: http://reviews.llvm.org/D20924
Added:
llvm/trunk/test/DebugInfo/COFF/types-data-members.ll
llvm/trunk/test/DebugInfo/COFF/types-recursive-struct.ll
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/ListRecordBuilder.h
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp
llvm/trunk/test/DebugInfo/COFF/types-basic.ll
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/ListRecordBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ListRecordBuilder.h?rev=271680&r1=271679&r2=271680&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/ListRecordBuilder.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/ListRecordBuilder.h Fri Jun 3 10:58:20 2016
@@ -28,7 +28,13 @@ protected:
public:
llvm::StringRef str() { return Builder.str(); }
- void reset(TypeRecordKind K) { Builder.reset(K); }
+ void reset(TypeRecordKind K) {
+ Builder.reset(K);
+ ContinuationOffsets.clear();
+ SubrecordCount = 0;
+ }
+
+ unsigned getSubrecordCount() { return SubrecordCount; }
protected:
void finishSubRecord();
@@ -38,6 +44,7 @@ protected:
private:
TypeRecordBuilder Builder;
SmallVector<size_t, 4> ContinuationOffsets;
+ unsigned SubrecordCount = 0;
};
}
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=271680&r1=271679&r2=271680&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Fri Jun 3 10:58:20 2016
@@ -13,6 +13,7 @@
#include "CodeViewDebug.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/FieldListRecordBuilder.h"
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/CodeView/TypeDumper.h"
@@ -138,12 +139,16 @@ TypeIndex CodeViewDebug::getFuncIdForSub
FuncIdRecord FuncId(ParentScope, getTypeIndex(SP->getType()), DisplayName);
TypeIndex TI = TypeTable.writeFuncId(FuncId);
- auto InsertResult = TypeIndices.insert({SP, TI});
- (void)InsertResult;
- assert(InsertResult.second && "DISubprogram lowered twice");
+ recordTypeIndexForDINode(SP, TI);
return TI;
}
+void CodeViewDebug::recordTypeIndexForDINode(const DINode *Node, TypeIndex TI) {
+ auto InsertResult = TypeIndices.insert({Node, TI});
+ (void)InsertResult;
+ assert(InsertResult.second && "DINode was already assigned a type index");
+}
+
void CodeViewDebug::recordLocalVariable(LocalVariable &&Var,
const DILocation *InlinedAt) {
if (InlinedAt) {
@@ -746,6 +751,11 @@ TypeIndex CodeViewDebug::lowerType(const
return lowerTypeModifier(cast<DIDerivedType>(Ty));
case dwarf::DW_TAG_subroutine_type:
return lowerTypeFunction(cast<DISubroutineType>(Ty));
+ case dwarf::DW_TAG_class_type:
+ case dwarf::DW_TAG_structure_type:
+ return lowerTypeClass(cast<DICompositeType>(Ty));
+ case dwarf::DW_TAG_union_type:
+ return lowerTypeUnion(cast<DICompositeType>(Ty));
default:
// Use the null type index.
return TypeIndex();
@@ -961,6 +971,135 @@ TypeIndex CodeViewDebug::lowerTypeFuncti
return TypeTable.writeProcedure(Procedure);
}
+static MemberAccess translateAccessFlags(unsigned RecordTag,
+ const DIType *Member) {
+ switch (Member->getFlags() & DINode::FlagAccessibility) {
+ case DINode::FlagPrivate: return MemberAccess::Private;
+ case DINode::FlagPublic: return MemberAccess::Public;
+ case DINode::FlagProtected: return MemberAccess::Protected;
+ case 0:
+ // If there was no explicit access control, provide the default for the tag.
+ return RecordTag == dwarf::DW_TAG_class_type ? MemberAccess::Private
+ : MemberAccess::Public;
+ }
+ llvm_unreachable("access flags are exclusive");
+}
+
+static TypeRecordKind getRecordKind(const DICompositeType *Ty) {
+ switch (Ty->getTag()) {
+ case dwarf::DW_TAG_class_type: return TypeRecordKind::Class;
+ case dwarf::DW_TAG_structure_type: return TypeRecordKind::Struct;
+ }
+ llvm_unreachable("unexpected tag");
+}
+
+/// Return the HasUniqueName option if it should be present in ClassOptions, or
+/// None otherwise.
+static ClassOptions getRecordUniqueNameOption(const DICompositeType *Ty) {
+ // MSVC always sets this flag now, even for local types. Clang doesn't always
+ // appear to give every type a linkage name, which may be problematic for us.
+ // FIXME: Investigate the consequences of not following them here.
+ return !Ty->getIdentifier().empty() ? ClassOptions::HasUniqueName
+ : ClassOptions::None;
+}
+
+TypeIndex CodeViewDebug::lowerTypeClass(const DICompositeType *Ty) {
+ // First, construct the forward decl. Don't look into Ty to compute the
+ // forward decl options, since it might not be available in all TUs.
+ TypeRecordKind Kind = getRecordKind(Ty);
+ ClassOptions CO =
+ ClassOptions::ForwardReference | getRecordUniqueNameOption(Ty);
+ TypeIndex FwdDeclTI = TypeTable.writeClass(ClassRecord(
+ Kind, 0, CO, HfaKind::None, WindowsRTClassKind::None, TypeIndex(),
+ TypeIndex(), TypeIndex(), 0, Ty->getName(), Ty->getIdentifier()));
+ return FwdDeclTI;
+}
+
+TypeIndex CodeViewDebug::lowerCompleteTypeClass(const DICompositeType *Ty) {
+ // Construct the field list and complete type record.
+ TypeRecordKind Kind = getRecordKind(Ty);
+ // FIXME: Other ClassOptions, like ContainsNestedClass and NestedClass.
+ ClassOptions CO = ClassOptions::None | getRecordUniqueNameOption(Ty);
+ TypeIndex FTI;
+ unsigned FieldCount;
+ std::tie(FTI, FieldCount) = lowerRecordFieldList(Ty);
+
+ uint64_t SizeInBytes = Ty->getSizeInBits() / 8;
+ return TypeTable.writeClass(ClassRecord(Kind, FieldCount, CO, HfaKind::None,
+ WindowsRTClassKind::None, FTI,
+ TypeIndex(), TypeIndex(), SizeInBytes,
+ Ty->getName(), Ty->getIdentifier()));
+ // FIXME: Make an LF_UDT_SRC_LINE record.
+}
+
+TypeIndex CodeViewDebug::lowerTypeUnion(const DICompositeType *Ty) {
+ ClassOptions CO =
+ ClassOptions::ForwardReference | getRecordUniqueNameOption(Ty);
+ TypeIndex FwdDeclTI =
+ TypeTable.writeUnion(UnionRecord(0, CO, HfaKind::None, TypeIndex(), 0,
+ Ty->getName(), Ty->getIdentifier()));
+ return FwdDeclTI;
+}
+
+TypeIndex CodeViewDebug::lowerCompleteTypeUnion(const DICompositeType *Ty) {
+ ClassOptions CO = ClassOptions::None | getRecordUniqueNameOption(Ty);
+ TypeIndex FTI;
+ unsigned FieldCount;
+ std::tie(FTI, FieldCount) = lowerRecordFieldList(Ty);
+ uint64_t SizeInBytes = Ty->getSizeInBits() / 8;
+ return TypeTable.writeUnion(UnionRecord(FieldCount, CO, HfaKind::None, FTI,
+ SizeInBytes, Ty->getName(),
+ Ty->getIdentifier()));
+ // FIXME: Make an LF_UDT_SRC_LINE record.
+}
+
+std::pair<TypeIndex, unsigned>
+CodeViewDebug::lowerRecordFieldList(const DICompositeType *Ty) {
+ // Manually count members. MSVC appears to count everything that generates a
+ // field list record. Each individual overload in a method overload group
+ // contributes to this count, even though the overload group is a single field
+ // list record.
+ unsigned MemberCount = 0;
+ FieldListRecordBuilder Fields;
+ for (const DINode *Element : Ty->getElements()) {
+ // We assume that the frontend provides all members in source declaration
+ // order, which is what MSVC does.
+ if (!Element)
+ continue;
+ if (auto *SP = dyn_cast<DISubprogram>(Element)) {
+ // C++ method.
+ // FIXME: Overloaded methods are grouped together, so we'll need two
+ // passes to group them.
+ (void)SP;
+ } else if (auto *Member = dyn_cast<DIDerivedType>(Element)) {
+ if (Member->getTag() == dwarf::DW_TAG_member) {
+ if (Member->isStaticMember()) {
+ // Static data member.
+ Fields.writeStaticDataMember(StaticDataMemberRecord(
+ translateAccessFlags(Ty->getTag(), Member),
+ getTypeIndex(Member->getBaseType()), Member->getName()));
+ MemberCount++;
+ } else {
+ // Data member.
+ // FIXME: Make a BitFieldRecord for bitfields.
+ Fields.writeDataMember(DataMemberRecord(
+ translateAccessFlags(Ty->getTag(), Member),
+ getTypeIndex(Member->getBaseType()),
+ Member->getOffsetInBits() / 8, Member->getName()));
+ MemberCount++;
+ }
+ } else if (Member->getTag() == dwarf::DW_TAG_friend) {
+ // Ignore friend members. It appears that MSVC emitted info about
+ // friends in the past, but modern versions do not.
+ }
+ // FIXME: Get clang to emit nested types here and do something with
+ // them.
+ }
+ // Skip other unrecognized kinds of elements.
+ }
+ return {TypeTable.writeFieldList(Fields), MemberCount};
+}
+
TypeIndex CodeViewDebug::getTypeIndex(DITypeRef TypeRef) {
const DIType *Ty = TypeRef.resolve();
@@ -968,16 +1107,70 @@ TypeIndex CodeViewDebug::getTypeIndex(DI
if (!Ty)
return TypeIndex::Void();
- // Check if we've already translated this type.
+ // Check if we've already translated this type. Don't try to do a
+ // get-or-create style insertion that caches the hash lookup across the
+ // lowerType call. It will update the TypeIndices map.
auto I = TypeIndices.find(Ty);
if (I != TypeIndices.end())
return I->second;
TypeIndex TI = lowerType(Ty);
- auto InsertResult = TypeIndices.insert({Ty, TI});
- (void)InsertResult;
- assert(InsertResult.second && "DIType lowered twice");
+ recordTypeIndexForDINode(Ty, TI);
+ return TI;
+}
+
+TypeIndex CodeViewDebug::getCompleteTypeIndex(DITypeRef TypeRef) {
+ const DIType *Ty = TypeRef.resolve();
+
+ // The null DIType is the void type. Don't try to hash it.
+ if (!Ty)
+ return TypeIndex::Void();
+
+ // If this is a non-record type, the complete type index is the same as the
+ // normal type index. Just call getTypeIndex.
+ switch (Ty->getTag()) {
+ case dwarf::DW_TAG_class_type:
+ case dwarf::DW_TAG_structure_type:
+ case dwarf::DW_TAG_union_type:
+ break;
+ default:
+ return getTypeIndex(Ty);
+ }
+
+ // Check if we've already translated the complete record type. Lowering a
+ // complete type should never trigger lowering another complete type, so we
+ // can reuse the hash table lookup result.
+ const auto *CTy = cast<DICompositeType>(Ty);
+ auto InsertResult = CompleteTypeIndices.insert({CTy, TypeIndex()});
+ if (!InsertResult.second)
+ return InsertResult.first->second;
+
+ // Make sure the forward declaration is emitted first. It's unclear if this
+ // is necessary, but MSVC does it, and we should follow suit until we can show
+ // otherwise.
+ TypeIndex FwdDeclTI = getTypeIndex(CTy);
+
+ // Just use the forward decl if we don't have complete type info. This might
+ // happen if the frontend is using modules and expects the complete definition
+ // to be emitted elsewhere.
+ if (CTy->isForwardDecl())
+ return FwdDeclTI;
+
+ TypeIndex TI;
+ switch (CTy->getTag()) {
+ case dwarf::DW_TAG_class_type:
+ case dwarf::DW_TAG_structure_type:
+ TI = lowerCompleteTypeClass(CTy);
+ break;
+ case dwarf::DW_TAG_union_type:
+ TI = lowerCompleteTypeUnion(CTy);
+ break;
+ default:
+ llvm_unreachable("not a record");
+ }
+
+ InsertResult.first->second = TI;
return TI;
}
@@ -999,7 +1192,7 @@ void CodeViewDebug::emitLocalVariable(co
Flags |= LocalSymFlags::IsOptimizedOut;
OS.AddComment("TypeIndex");
- TypeIndex TI = getTypeIndex(Var.DIVar->getType());
+ TypeIndex TI = getCompleteTypeIndex(Var.DIVar->getType());
OS.EmitIntValue(TI.getIndex(), 4);
OS.AddComment("Flags");
OS.EmitIntValue(static_cast<uint16_t>(Flags), 2);
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=271680&r1=271679&r2=271680&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Fri Jun 3 10:58:20 2016
@@ -140,6 +140,10 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
/// DIType* and DISubprogram*.
DenseMap<const DINode *, codeview::TypeIndex> TypeIndices;
+ /// Map from DICompositeType* to complete type index. Non-record types are
+ /// always looked up in the normal TypeIndices map.
+ DenseMap<const DICompositeType *, codeview::TypeIndex> CompleteTypeIndices;
+
typedef std::map<const DIFile *, std::string> FileToFilepathMapTy;
FileToFilepathMapTy FileToFilepathMap;
StringRef getFullFilepath(const DIFile *S);
@@ -182,7 +186,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
/// Translates the DIType to codeview if necessary and returns a type index
/// for it.
- codeview::TypeIndex getTypeIndex(DITypeRef Ty);
+ codeview::TypeIndex getTypeIndex(DITypeRef TypeRef);
codeview::TypeIndex lowerType(const DIType *Ty);
codeview::TypeIndex lowerTypeAlias(const DIDerivedType *Ty);
@@ -191,6 +195,27 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
codeview::TypeIndex lowerTypeMemberPointer(const DIDerivedType *Ty);
codeview::TypeIndex lowerTypeModifier(const DIDerivedType *Ty);
codeview::TypeIndex lowerTypeFunction(const DISubroutineType *Ty);
+ codeview::TypeIndex lowerTypeClass(const DICompositeType *Ty);
+ codeview::TypeIndex lowerTypeUnion(const DICompositeType *Ty);
+
+ /// Symbol records should point to complete types, but type records should
+ /// always point to incomplete types to avoid cycles in the type graph. Only
+ /// use this entry point when generating symbol records. The complete and
+ /// incomplete type indices only differ for record types. All other types use
+ /// the same index.
+ codeview::TypeIndex getCompleteTypeIndex(DITypeRef TypeRef);
+
+ codeview::TypeIndex lowerCompleteTypeClass(const DICompositeType *Ty);
+ codeview::TypeIndex lowerCompleteTypeUnion(const DICompositeType *Ty);
+
+ /// Common record member lowering functionality for record types, which are
+ /// structs, classes, and unions. Returns the field list index and the member
+ /// count.
+ std::pair<codeview::TypeIndex, unsigned>
+ lowerRecordFieldList(const DICompositeType *Ty);
+
+ /// Inserts {Node, TI} into TypeIndices and checks for duplicates.
+ void recordTypeIndexForDINode(const DINode *Node, codeview::TypeIndex TI);
public:
CodeViewDebug(AsmPrinter *Asm);
Modified: llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp?rev=271680&r1=271679&r2=271680&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/ListRecordBuilder.cpp Fri Jun 3 10:58:20 2016
@@ -15,6 +15,8 @@ using namespace codeview;
ListRecordBuilder::ListRecordBuilder(TypeRecordKind Kind) : Builder(Kind) {}
void ListRecordBuilder::finishSubRecord() {
+ SubrecordCount++;
+
// The builder starts at offset 2 in the actual CodeView buffer, so add an
// additional offset of 2 before computing the alignment.
uint32_t Remainder = (Builder.size() + 2) % 4;
Modified: llvm/trunk/test/DebugInfo/COFF/types-basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/types-basic.ll?rev=271680&r1=271679&r2=271680&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/types-basic.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/types-basic.ll Fri Jun 3 10:58:20 2016
@@ -33,6 +33,8 @@
; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
; CHECK: CodeViewTypes [
+; CHECK: Section: .debug$T (6)
+; CHECK: Magic: 0x4
; CHECK: ArgList (0x1000) {
; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
; CHECK: NumArgs: 3
@@ -75,7 +77,19 @@
; CHECK: IsVolatile: 0
; CHECK: IsUnaligned: 0
; CHECK: }
-; CHECK: Pointer (0x1005) {
+; CHECK: Struct (0x1005) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: A
+; CHECK: }
+; CHECK: Pointer (0x1006) {
; CHECK: TypeLeafKind: LF_POINTER (0x1002)
; CHECK: PointeeType: int (0x74)
; CHECK: PointerAttributes: 0x804C
@@ -85,28 +99,39 @@
; CHECK: IsConst: 0
; CHECK: IsVolatile: 0
; CHECK: IsUnaligned: 0
-; CHECK: ClassType: 0x0
+; CHECK: ClassType: A (0x1005)
; CHECK: Representation: Unknown (0x0)
; CHECK: }
-; CHECK: ArgList (0x1006) {
+; CHECK: Pointer (0x1007) {
+; CHECK: TypeLeafKind: LF_POINTER (0x1002)
+; CHECK: PointeeType: A (0x1005)
+; CHECK: PointerAttributes: 0x1000C
+; CHECK: PtrType: Near64 (0xC)
+; CHECK: PtrMode: Pointer (0x0)
+; CHECK: IsFlat: 0
+; CHECK: IsConst: 0
+; CHECK: IsVolatile: 0
+; CHECK: IsUnaligned: 0
+; CHECK: }
+; CHECK: ArgList (0x1008) {
; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
; CHECK: NumArgs: 1
; CHECK: Arguments [
-; CHECK: ArgType: <unknown simple type> (0x600)
+; CHECK: ArgType: A* (0x1007)
; CHECK: ]
; CHECK: }
-; CHECK: Procedure (0x1007) {
+; CHECK: Procedure (0x1009) {
; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
; CHECK: ReturnType: void (0x3)
; CHECK: CallingConvention: NearC (0x0)
; CHECK: FunctionOptions [ (0x0)
; CHECK: ]
; CHECK: NumParameters: 1
-; CHECK: ArgListType: (<unknown simple type>) (0x1006)
+; CHECK: ArgListType: (A*) (0x1008)
; CHECK: }
-; CHECK: Pointer (0x1008) {
+; CHECK: Pointer (0x100A) {
; CHECK: TypeLeafKind: LF_POINTER (0x1002)
-; CHECK: PointeeType: void (<unknown simple type>) (0x1007)
+; CHECK: PointeeType: void (A*) (0x1009)
; CHECK: PointerAttributes: 0x1006C
; CHECK: PtrType: Near64 (0xC)
; CHECK: PtrMode: PointerToMemberFunction (0x3)
@@ -114,19 +139,19 @@
; CHECK: IsConst: 0
; CHECK: IsVolatile: 0
; CHECK: IsUnaligned: 0
-; CHECK: ClassType: 0x0
+; CHECK: ClassType: A (0x1005)
; CHECK: Representation: Unknown (0x0)
; CHECK: }
-; CHECK: Modifier (0x1009) {
+; CHECK: Modifier (0x100B) {
; CHECK: TypeLeafKind: LF_MODIFIER (0x1001)
; CHECK: ModifiedType: void (0x3)
; CHECK: Modifiers [ (0x1)
; CHECK: Const (0x1)
; CHECK: ]
; CHECK: }
-; CHECK: Pointer (0x100A) {
+; CHECK: Pointer (0x100C) {
; CHECK: TypeLeafKind: LF_POINTER (0x1002)
-; CHECK: PointeeType: const void (0x1009)
+; CHECK: PointeeType: const void (0x100B)
; CHECK: PointerAttributes: 0x1000C
; CHECK: PtrType: Near64 (0xC)
; CHECK: PtrMode: Pointer (0x0)
@@ -135,7 +160,29 @@
; CHECK: IsVolatile: 0
; CHECK: IsUnaligned: 0
; CHECK: }
+; CHECK: ArgList (0x100D) {
+; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
+; CHECK: NumArgs: 0
+; CHECK: Arguments [
+; CHECK: ]
+; CHECK: }
+; CHECK: Procedure (0x100E) {
+; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
+; CHECK: ReturnType: void (0x3)
+; CHECK: CallingConvention: NearC (0x0)
+; CHECK: FunctionOptions [ (0x0)
+; CHECK: ]
+; CHECK: NumParameters: 0
+; CHECK: ArgListType: () (0x100D)
+; CHECK: }
+; CHECK: FuncId (0x100F) {
+; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
+; CHECK: ParentScope: 0x0
+; CHECK: FunctionType: void () (0x100E)
+; CHECK: Name: CharTypes
+; CHECK: }
; CHECK: ]
+
; CHECK: CodeViewDebugInfo [
; CHECK: Subsection [
; CHECK: SubSectionType: Symbols (0xF1)
@@ -188,11 +235,11 @@
; CHECK: VarName: v3
; CHECK: }
; CHECK: Local {
-; CHECK: Type: int <no type>::* (0x1005)
+; CHECK: Type: int A::* (0x1006)
; CHECK: VarName: v4
; CHECK: }
; CHECK: Local {
-; CHECK: Type: void (<unknown simple type>) <no type>::* (0x1008)
+; CHECK: Type: void (A*) A::* (0x100A)
; CHECK: VarName: v5
; CHECK: }
; CHECK: Local {
@@ -212,7 +259,7 @@
; CHECK: VarName: l4
; CHECK: }
; CHECK: Local {
-; CHECK: Type: const void* (0x100A)
+; CHECK: Type: const void* (0x100C)
; CHECK: VarName: v6
; CHECK: }
; CHECK: ProcEnd {
@@ -220,6 +267,7 @@
; CHECK: ]
; CHECK: Subsection [
; CHECK: ProcStart {
+; CHECK: Type: CharTypes (0x100F)
; CHECK: DisplayName: CharTypes
; CHECK: LinkageName: ?CharTypes@@YAXXZ
; CHECK: }
Added: llvm/trunk/test/DebugInfo/COFF/types-data-members.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/types-data-members.ll?rev=271680&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/types-data-members.ll (added)
+++ llvm/trunk/test/DebugInfo/COFF/types-data-members.ll Fri Jun 3 10:58:20 2016
@@ -0,0 +1,473 @@
+; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
+
+; C++ source to regenerate:
+; $ cat t.cpp
+; struct Struct {
+; int s1;
+; int s2;
+; int s3;
+; static const int sdm = 3;
+; };
+; union Union {
+; int a;
+; float b;
+; };
+; class Class {
+; public:
+; int pub;
+; struct Nested;
+; private:
+; int priv;
+; protected:
+; int prot;
+; };
+; struct DerivedClass : Struct, virtual Class {
+; int d;
+; };
+; struct Class::Nested {
+; int n;
+; };
+; void UseTypes() {
+; Struct s;
+; Union u;
+; Class c;
+; DerivedClass dc;
+; Class::Nested n;
+; }
+; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
+
+; CHECK: CodeViewTypes [
+; CHECK: Section: .debug$T (10)
+; CHECK: Magic: 0x4
+; CHECK: ArgList (0x1000) {
+; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
+; CHECK: NumArgs: 0
+; CHECK: Arguments [
+; CHECK: ]
+; CHECK: }
+; CHECK: Procedure (0x1001) {
+; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
+; CHECK: ReturnType: void (0x3)
+; CHECK: CallingConvention: NearC (0x0)
+; CHECK: FunctionOptions [ (0x0)
+; CHECK: ]
+; CHECK: NumParameters: 0
+; CHECK: ArgListType: () (0x1000)
+; CHECK: }
+; CHECK: FuncId (0x1002) {
+; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
+; CHECK: ParentScope: 0x0
+; CHECK: FunctionType: void () (0x1001)
+; CHECK: Name: UseTypes
+; CHECK: }
+; CHECK: Struct (0x1003) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: Struct
+; CHECK: }
+; CHECK: Modifier (0x1004) {
+; CHECK: TypeLeafKind: LF_MODIFIER (0x1001)
+; CHECK: ModifiedType: int (0x74)
+; CHECK: Modifiers [ (0x1)
+; CHECK: Const (0x1)
+; CHECK: ]
+; CHECK: }
+; CHECK: UnknownLeaf (0x1005) {
+; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: s1
+; CHECK: }
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x4
+; CHECK: Name: s2
+; CHECK: }
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x8
+; CHECK: Name: s3
+; CHECK: }
+; CHECK: StaticDataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: const int (0x1004)
+; CHECK: Name: sdm
+; CHECK: }
+; CHECK: }
+; CHECK: Struct (0x1006) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 4
+; CHECK: Properties [ (0x0)
+; CHECK: ]
+; CHECK: FieldList: sdm (0x1005)
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 12
+; CHECK: Name: Struct
+; CHECK: }
+; CHECK: Union (0x1007) {
+; CHECK: TypeLeafKind: LF_UNION (0x1506)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: Union
+; CHECK: }
+; CHECK: UnknownLeaf (0x1008) {
+; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: a
+; CHECK: }
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: float (0x40)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: b
+; CHECK: }
+; CHECK: }
+; CHECK: Union (0x1009) {
+; CHECK: TypeLeafKind: LF_UNION (0x1506)
+; CHECK: MemberCount: 2
+; CHECK: Properties [ (0x0)
+; CHECK: ]
+; CHECK: FieldList: b (0x1008)
+; CHECK: SizeOf: 4
+; CHECK: Name: Union
+; CHECK: }
+; CHECK: Class (0x100A) {
+; CHECK: TypeLeafKind: LF_CLASS (0x1504)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: Class
+; CHECK: }
+; CHECK: UnknownLeaf (0x100B) {
+; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: pub
+; CHECK: }
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Private (0x1)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x4
+; CHECK: Name: priv
+; CHECK: }
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Protected (0x2)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x8
+; CHECK: Name: prot
+; CHECK: }
+; CHECK: }
+; CHECK: Class (0x100C) {
+; CHECK: TypeLeafKind: LF_CLASS (0x1504)
+; CHECK: MemberCount: 3
+; CHECK: Properties [ (0x0)
+; CHECK: ]
+; CHECK: FieldList: prot (0x100B)
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 12
+; CHECK: Name: Class
+; CHECK: }
+; CHECK: Struct (0x100D) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: DerivedClass
+; CHECK: }
+; CHECK: Procedure (0x100E) {
+; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
+; CHECK: ReturnType: int (0x74)
+; CHECK: CallingConvention: NearC (0x0)
+; CHECK: FunctionOptions [ (0x0)
+; CHECK: ]
+; CHECK: NumParameters: 0
+; CHECK: ArgListType: () (0x1000)
+; CHECK: }
+; CHECK: Pointer (0x100F) {
+; CHECK: TypeLeafKind: LF_POINTER (0x1002)
+; CHECK: PointeeType: int () (0x100E)
+; CHECK: PointerAttributes: 0x1000C
+; CHECK: PtrType: Near64 (0xC)
+; CHECK: PtrMode: Pointer (0x0)
+; CHECK: IsFlat: 0
+; CHECK: IsConst: 0
+; CHECK: IsVolatile: 0
+; CHECK: IsUnaligned: 0
+; CHECK: }
+; CHECK: Pointer (0x1010) {
+; CHECK: TypeLeafKind: LF_POINTER (0x1002)
+; CHECK: PointeeType: int ()* (0x100F)
+; CHECK: PointerAttributes: 0x1000C
+; CHECK: PtrType: Near64 (0xC)
+; CHECK: PtrMode: Pointer (0x0)
+; CHECK: IsFlat: 0
+; CHECK: IsConst: 0
+; CHECK: IsVolatile: 0
+; CHECK: IsUnaligned: 0
+; CHECK: }
+; CHECK: UnknownLeaf (0x1011) {
+; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int ()** (0x1010)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: _vptr$DerivedClass
+; CHECK: }
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x18
+; CHECK: Name: d
+; CHECK: }
+; CHECK: }
+; CHECK: Struct (0x1012) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 2
+; CHECK: Properties [ (0x0)
+; CHECK: ]
+; CHECK: FieldList: d (0x1011)
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 48
+; CHECK: Name: DerivedClass
+; CHECK: }
+; CHECK: Struct (0x1013) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: Nested
+; CHECK: }
+; CHECK: UnknownLeaf (0x1014) {
+; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: int (0x74)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: n
+; CHECK: }
+; CHECK: }
+; CHECK: Struct (0x1015) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 1
+; CHECK: Properties [ (0x0)
+; CHECK: ]
+; CHECK: FieldList: n (0x1014)
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 4
+; CHECK: Name: Nested
+; CHECK: }
+; CHECK: Pointer (0x1016) {
+; CHECK: TypeLeafKind: LF_POINTER (0x1002)
+; CHECK: PointeeType: DerivedClass (0x100D)
+; CHECK: PointerAttributes: 0x1000C
+; CHECK: PtrType: Near64 (0xC)
+; CHECK: PtrMode: Pointer (0x0)
+; CHECK: IsFlat: 0
+; CHECK: IsConst: 0
+; CHECK: IsVolatile: 0
+; CHECK: IsUnaligned: 0
+; CHECK: }
+; CHECK: ArgList (0x1017) {
+; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
+; CHECK: NumArgs: 1
+; CHECK: Arguments [
+; CHECK: ArgType: DerivedClass* (0x1016)
+; CHECK: ]
+; CHECK: }
+; CHECK: Procedure (0x1018) {
+; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
+; CHECK: ReturnType: void (0x3)
+; CHECK: CallingConvention: NearC (0x0)
+; CHECK: FunctionOptions [ (0x0)
+; CHECK: ]
+; CHECK: NumParameters: 1
+; CHECK: ArgListType: (DerivedClass*) (0x1017)
+; CHECK: }
+; CHECK: FuncId (0x1019) {
+; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
+; CHECK: ParentScope: 0x0
+; CHECK: FunctionType: void (DerivedClass*) (0x1018)
+; CHECK: Name: DerivedClass::DerivedClass
+; CHECK: }
+; CHECK: ]
+
+; ModuleID = 'record-types.cpp'
+source_filename = "record-types.cpp"
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.23918"
+
+%struct.Struct = type { i32, i32, i32 }
+%union.Union = type { i32 }
+%class.Class = type { i32, i32, i32 }
+%struct.DerivedClass = type { %struct.Struct, i32*, i32, [4 x i8], %class.Class }
+%"struct.Class::Nested" = type { i32 }
+
+$"\01??0DerivedClass@@QEAA at XZ" = comdat any
+
+$"\01??_8DerivedClass@@7B@" = comdat any
+
+@"\01??_8DerivedClass@@7B@" = linkonce_odr unnamed_addr constant [2 x i32] [i32 -16, i32 16], comdat
+
+; Function Attrs: nounwind uwtable
+define void @"\01?UseTypes@@YAXXZ"() #0 !dbg !7 {
+entry:
+ %s = alloca %struct.Struct, align 4
+ %u = alloca %union.Union, align 4
+ %c = alloca %class.Class, align 4
+ %dc = alloca %struct.DerivedClass, align 8
+ %n = alloca %"struct.Class::Nested", align 4
+ call void @llvm.dbg.declare(metadata %struct.Struct* %s, metadata !10, metadata !19), !dbg !20
+ call void @llvm.dbg.declare(metadata %union.Union* %u, metadata !21, metadata !19), !dbg !27
+ call void @llvm.dbg.declare(metadata %class.Class* %c, metadata !28, metadata !19), !dbg !34
+ call void @llvm.dbg.declare(metadata %struct.DerivedClass* %dc, metadata !35, metadata !19), !dbg !46
+ %call = call %struct.DerivedClass* @"\01??0DerivedClass@@QEAA at XZ"(%struct.DerivedClass* %dc, i32 1) #3, !dbg !46
+ call void @llvm.dbg.declare(metadata %"struct.Class::Nested"* %n, metadata !47, metadata !19), !dbg !51
+ ret void, !dbg !52
+}
+
+; Function Attrs: nounwind readnone
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+; Function Attrs: inlinehint nounwind uwtable
+define linkonce_odr %struct.DerivedClass* @"\01??0DerivedClass@@QEAA at XZ"(%struct.DerivedClass* returned %this, i32 %is_most_derived) unnamed_addr #2 comdat align 2 !dbg !53 {
+entry:
+ %retval = alloca %struct.DerivedClass*, align 8
+ %is_most_derived.addr = alloca i32, align 4
+ %this.addr = alloca %struct.DerivedClass*, align 8
+ store i32 %is_most_derived, i32* %is_most_derived.addr, align 4
+ call void @llvm.dbg.declare(metadata i32* %is_most_derived.addr, metadata !58, metadata !19), !dbg !59
+ store %struct.DerivedClass* %this, %struct.DerivedClass** %this.addr, align 8
+ call void @llvm.dbg.declare(metadata %struct.DerivedClass** %this.addr, metadata !60, metadata !19), !dbg !59
+ %this1 = load %struct.DerivedClass*, %struct.DerivedClass** %this.addr, align 8
+ store %struct.DerivedClass* %this1, %struct.DerivedClass** %retval, align 8
+ %is_most_derived2 = load i32, i32* %is_most_derived.addr, align 4
+ %is_complete_object = icmp ne i32 %is_most_derived2, 0, !dbg !62
+ br i1 %is_complete_object, label %ctor.init_vbases, label %ctor.skip_vbases, !dbg !62
+
+ctor.init_vbases: ; preds = %entry
+ %this.int8 = bitcast %struct.DerivedClass* %this1 to i8*, !dbg !62
+ %0 = getelementptr inbounds i8, i8* %this.int8, i64 16, !dbg !62
+ %vbptr.DerivedClass = bitcast i8* %0 to i32**, !dbg !62
+ store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"\01??_8DerivedClass@@7B@", i32 0, i32 0), i32** %vbptr.DerivedClass, align 8, !dbg !62
+ %1 = bitcast %struct.DerivedClass* %this1 to i8*, !dbg !62
+ %2 = getelementptr inbounds i8, i8* %1, i64 32, !dbg !62
+ %3 = bitcast i8* %2 to %class.Class*, !dbg !62
+ br label %ctor.skip_vbases, !dbg !62
+
+ctor.skip_vbases: ; preds = %ctor.init_vbases, %entry
+ %4 = bitcast %struct.DerivedClass* %this1 to %struct.Struct*, !dbg !62
+ %5 = load %struct.DerivedClass*, %struct.DerivedClass** %retval, align 8, !dbg !62
+ ret %struct.DerivedClass* %5, !dbg !62
+}
+
+attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind readnone }
+attributes #2 = { inlinehint nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #3 = { nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 271336) (llvm/trunk 271339)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "record-types.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"PIC Level", i32 2}
+!6 = !{!"clang version 3.9.0 (trunk 271336) (llvm/trunk 271339)"}
+!7 = distinct !DISubprogram(name: "UseTypes", linkageName: "\01?UseTypes@@YAXXZ", scope: !1, file: !1, line: 31, type: !8, isLocal: false, isDefinition: true, scopeLine: 31, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !DILocalVariable(name: "s", scope: !7, file: !1, line: 32, type: !11)
+!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Struct", file: !1, line: 1, size: 96, align: 32, elements: !12)
+!12 = !{!13, !15, !16, !17}
+!13 = !DIDerivedType(tag: DW_TAG_member, name: "s1", scope: !11, file: !1, line: 2, baseType: !14, size: 32, align: 32)
+!14 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!15 = !DIDerivedType(tag: DW_TAG_member, name: "s2", scope: !11, file: !1, line: 3, baseType: !14, size: 32, align: 32, offset: 32)
+!16 = !DIDerivedType(tag: DW_TAG_member, name: "s3", scope: !11, file: !1, line: 4, baseType: !14, size: 32, align: 32, offset: 64)
+!17 = !DIDerivedType(tag: DW_TAG_member, name: "sdm", scope: !11, file: !1, line: 5, baseType: !18, flags: DIFlagStaticMember, extraData: i32 3)
+!18 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14)
+!19 = !DIExpression()
+!20 = !DILocation(line: 32, column: 10, scope: !7)
+!21 = !DILocalVariable(name: "u", scope: !7, file: !1, line: 33, type: !22)
+!22 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "Union", file: !1, line: 8, size: 32, align: 32, elements: !23)
+!23 = !{!24, !25}
+!24 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !22, file: !1, line: 9, baseType: !14, size: 32, align: 32)
+!25 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !22, file: !1, line: 10, baseType: !26, size: 32, align: 32)
+!26 = !DIBasicType(name: "float", size: 32, align: 32, encoding: DW_ATE_float)
+!27 = !DILocation(line: 33, column: 9, scope: !7)
+!28 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 34, type: !29)
+!29 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "Class", file: !1, line: 13, size: 96, align: 32, elements: !30)
+!30 = !{!31, !32, !33}
+!31 = !DIDerivedType(tag: DW_TAG_member, name: "pub", scope: !29, file: !1, line: 15, baseType: !14, size: 32, align: 32, flags: DIFlagPublic)
+!32 = !DIDerivedType(tag: DW_TAG_member, name: "priv", scope: !29, file: !1, line: 18, baseType: !14, size: 32, align: 32, offset: 32)
+!33 = !DIDerivedType(tag: DW_TAG_member, name: "prot", scope: !29, file: !1, line: 20, baseType: !14, size: 32, align: 32, offset: 64, flags: DIFlagProtected)
+!34 = !DILocation(line: 34, column: 9, scope: !7)
+!35 = !DILocalVariable(name: "dc", scope: !7, file: !1, line: 35, type: !36)
+!36 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DerivedClass", file: !1, line: 23, size: 384, align: 64, elements: !37, vtableHolder: !36)
+!37 = !{!38, !39, !40, !45}
+!38 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !36, baseType: !11)
+!39 = !DIDerivedType(tag: DW_TAG_inheritance, scope: !36, baseType: !29, offset: 4, flags: DIFlagVirtual)
+!40 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$DerivedClass", scope: !1, file: !1, baseType: !41, size: 64, flags: DIFlagArtificial)
+!41 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !42, size: 64)
+!42 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", baseType: !43, size: 64)
+!43 = !DISubroutineType(types: !44)
+!44 = !{!14}
+!45 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !36, file: !1, line: 24, baseType: !14, size: 32, align: 32, offset: 192)
+!46 = !DILocation(line: 35, column: 16, scope: !7)
+!47 = !DILocalVariable(name: "n", scope: !7, file: !1, line: 36, type: !48)
+!48 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", scope: !29, file: !1, line: 27, size: 32, align: 32, elements: !49)
+!49 = !{!50}
+!50 = !DIDerivedType(tag: DW_TAG_member, name: "n", scope: !48, file: !1, line: 28, baseType: !14, size: 32, align: 32)
+!51 = !DILocation(line: 36, column: 17, scope: !7)
+!52 = !DILocation(line: 37, column: 1, scope: !7)
+!53 = distinct !DISubprogram(name: "DerivedClass::DerivedClass", linkageName: "\01??0DerivedClass@@QEAA at XZ", scope: !36, file: !1, line: 23, type: !54, isLocal: false, isDefinition: true, scopeLine: 23, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !57, variables: !2)
+!54 = !DISubroutineType(types: !55)
+!55 = !{null, !56}
+!56 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !36, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!57 = !DISubprogram(name: "DerivedClass::DerivedClass", scope: !36, type: !54, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
+!58 = !DILocalVariable(name: "is_most_derived", arg: 2, scope: !53, type: !14, flags: DIFlagArtificial)
+!59 = !DILocation(line: 0, scope: !53)
+!60 = !DILocalVariable(name: "this", arg: 1, scope: !53, type: !61, flags: DIFlagArtificial | DIFlagObjectPointer)
+!61 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !36, size: 64, align: 64)
+!62 = !DILocation(line: 23, column: 8, scope: !53)
Added: llvm/trunk/test/DebugInfo/COFF/types-recursive-struct.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/types-recursive-struct.ll?rev=271680&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/types-recursive-struct.ll (added)
+++ llvm/trunk/test/DebugInfo/COFF/types-recursive-struct.ll Fri Jun 3 10:58:20 2016
@@ -0,0 +1,172 @@
+; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
+
+; This test ensures that circular type references through pointer types don't
+; cause infinite recursion. It also tests that we always refer to the forward
+; declaration type index in field lists and pointer types, which is consistent
+; with what MSVC does. It ensures that these records get merged when merging
+; streams even if the complete record types differ slightly due to ODR
+; violations, i.e. methods that only exist ifndef NDEBUG.
+
+; C++ source to regenerate:
+; $ cat t.cpp
+; struct B;
+; struct A { B *b; };
+; struct B { A a; };
+; void f() {
+; A a;
+; B b;
+; }
+; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
+
+; CHECK: CodeViewTypes [
+; CHECK: Section: .debug$T (6)
+; CHECK: Magic: 0x4
+; CHECK: ArgList (0x1000) {
+; CHECK: TypeLeafKind: LF_ARGLIST (0x1201)
+; CHECK: NumArgs: 0
+; CHECK: Arguments [
+; CHECK: ]
+; CHECK: }
+; CHECK: Procedure (0x1001) {
+; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
+; CHECK: ReturnType: void (0x3)
+; CHECK: CallingConvention: NearC (0x0)
+; CHECK: FunctionOptions [ (0x0)
+; CHECK: ]
+; CHECK: NumParameters: 0
+; CHECK: ArgListType: () (0x1000)
+; CHECK: }
+; CHECK: FuncId (0x1002) {
+; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
+; CHECK: ParentScope: 0x0
+; CHECK: FunctionType: void () (0x1001)
+; CHECK: Name: f
+; CHECK: }
+; CHECK: Struct (0x1003) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: A
+; CHECK: }
+; CHECK: Struct (0x1004) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 0
+; CHECK: Properties [ (0x80)
+; CHECK: ForwardReference (0x80)
+; CHECK: ]
+; CHECK: FieldList: 0x0
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 0
+; CHECK: Name: B
+; CHECK: }
+; CHECK: Pointer (0x1005) {
+; CHECK: TypeLeafKind: LF_POINTER (0x1002)
+; CHECK: PointeeType: B (0x1004)
+; CHECK: PointerAttributes: 0x1000C
+; CHECK: PtrType: Near64 (0xC)
+; CHECK: PtrMode: Pointer (0x0)
+; CHECK: IsFlat: 0
+; CHECK: IsConst: 0
+; CHECK: IsVolatile: 0
+; CHECK: IsUnaligned: 0
+; CHECK: }
+; CHECK: UnknownLeaf (0x1006) {
+; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: B* (0x1005)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: b
+; CHECK: }
+; CHECK: }
+; CHECK: Struct (0x1007) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 1
+; CHECK: Properties [ (0x0)
+; CHECK: ]
+; CHECK: FieldList: b (0x1006)
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 8
+; CHECK: Name: A
+; CHECK: }
+; CHECK: UnknownLeaf (0x1008) {
+; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
+; CHECK: DataMember {
+; CHECK: AccessSpecifier: Public (0x3)
+; CHECK: Type: A (0x1003)
+; CHECK: FieldOffset: 0x0
+; CHECK: Name: a
+; CHECK: }
+; CHECK: }
+; CHECK: Struct (0x1009) {
+; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
+; CHECK: MemberCount: 1
+; CHECK: Properties [ (0x0)
+; CHECK: ]
+; CHECK: FieldList: a (0x1008)
+; CHECK: DerivedFrom: 0x0
+; CHECK: VShape: 0x0
+; CHECK: SizeOf: 8
+; CHECK: Name: B
+; CHECK: }
+; CHECK: ]
+
+; ModuleID = 't.cpp'
+source_filename = "t.cpp"
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.0.23918"
+
+%struct.A = type { %struct.B* }
+%struct.B = type { %struct.A }
+
+; Function Attrs: nounwind uwtable
+define void @"\01?f@@YAXXZ"() #0 !dbg !7 {
+entry:
+ %a = alloca %struct.A, align 8
+ %b = alloca %struct.B, align 8
+ call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !10, metadata !18), !dbg !19
+ call void @llvm.dbg.declare(metadata %struct.B* %b, metadata !20, metadata !18), !dbg !21
+ ret void, !dbg !22
+}
+
+; Function Attrs: nounwind readnone
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind readnone }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"PIC Level", i32 2}
+!6 = !{!"clang version 3.9.0 "}
+!7 = distinct !DISubprogram(name: "f", linkageName: "\01?f@@YAXXZ", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !DILocalVariable(name: "a", scope: !7, file: !1, line: 5, type: !11)
+!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A", file: !1, line: 2, size: 64, align: 64, elements: !12)
+!12 = !{!13}
+!13 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !11, file: !1, line: 2, baseType: !14, size: 64, align: 64)
+!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64, align: 64)
+!15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 3, size: 64, align: 64, elements: !16)
+!16 = !{!17}
+!17 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !15, file: !1, line: 3, baseType: !11, size: 64, align: 64)
+!18 = !DIExpression()
+!19 = !DILocation(line: 5, column: 5, scope: !7)
+!20 = !DILocalVariable(name: "b", scope: !7, file: !1, line: 6, type: !15)
+!21 = !DILocation(line: 6, column: 5, scope: !7)
+!22 = !DILocation(line: 7, column: 1, scope: !7)
More information about the llvm-commits
mailing list