[llvm] r274661 - Retry: "Emit CodeView type records for nested classes."
Adrian McCarthy via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 15:10:22 PDT 2016
This wasn't actually a revert. It was another attempt to land the patch,
with a correction to the new test to account for changes made by others
between the LGTM and the dcommit.
Good to know about those scripts. Is anybody working on Windows-compatible
versions of them? :-)
On Fri, Jul 8, 2016 at 3:01 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> On Wed, Jul 6, 2016 at 12:49 PM, Adrian McCarthy via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: amccarth
>> Date: Wed Jul 6 14:49:51 2016
>> New Revision: 274661
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=274661&view=rev
>> Log:
>> Retry: "Emit CodeView type records for nested classes."
>>
>> Now with a corrected test to account for a recently supported properties
>> bit in the debug info of a struct.
>>
>> Original review: http://reviews.llvm.org/D21939
>>
>> This reverts commit 970c3fd497a28d25dd69526eb52594a696c37968.
>>
>
> Best to include SVN revisions in the commit log so it's easy for everyone
> to follow.
>
> LLVM has a utility for this: utils/git-svn/git-svnrevert that works just
> like git revert, but produces a commit message that has the SVN revision
> number instead of the git hash.
>
>
>>
>> Added:
>> llvm/trunk/test/DebugInfo/COFF/types-nested-class.ll
>> Modified:
>> llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
>> llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=274661&r1=274660&r2=274661&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed Jul 6
>> 14:49:51 2016
>> @@ -1414,6 +1414,8 @@ struct llvm::ClassInfo {
>> MemberList Members;
>> // Direct overloaded methods gathered by name.
>> MethodsMap Methods;
>> +
>> + std::vector<const DICompositeType *> NestedClasses;
>> };
>>
>> void CodeViewDebug::clear() {
>> @@ -1466,8 +1468,8 @@ ClassInfo CodeViewDebug::collectClassInf
>> // friends in the past, but modern versions do not.
>> }
>> // FIXME: Get Clang to emit function virtual table here and handle
>> it.
>> - // FIXME: Get clang to emit nested types here and do something with
>> - // them.
>> + } else if (auto *Composite = dyn_cast<DICompositeType>(Element)) {
>> + Info.NestedClasses.push_back(Composite);
>> }
>> // Skip other unrecognized kinds of elements.
>> }
>> @@ -1496,7 +1498,12 @@ TypeIndex CodeViewDebug::lowerCompleteTy
>> TypeIndex FieldTI;
>> TypeIndex VShapeTI;
>> unsigned FieldCount;
>> - std::tie(FieldTI, VShapeTI, FieldCount) = lowerRecordFieldList(Ty);
>> + bool ContainsNestedClass;
>> + std::tie(FieldTI, VShapeTI, FieldCount, ContainsNestedClass) =
>> + lowerRecordFieldList(Ty);
>> +
>> + if (ContainsNestedClass)
>> + CO |= ClassOptions::ContainsNestedClass;
>>
>> std::string FullName = getFullyQualifiedName(Ty);
>>
>> @@ -1532,7 +1539,13 @@ TypeIndex CodeViewDebug::lowerCompleteTy
>> ClassOptions CO = getCommonClassOptions(Ty);
>> TypeIndex FieldTI;
>> unsigned FieldCount;
>> - std::tie(FieldTI, std::ignore, FieldCount) = lowerRecordFieldList(Ty);
>> + bool ContainsNestedClass;
>> + std::tie(FieldTI, std::ignore, FieldCount, ContainsNestedClass) =
>> + lowerRecordFieldList(Ty);
>> +
>> + if (ContainsNestedClass)
>> + CO |= ClassOptions::ContainsNestedClass;
>> +
>> uint64_t SizeInBytes = Ty->getSizeInBits() / 8;
>> std::string FullName = getFullyQualifiedName(Ty);
>>
>> @@ -1550,7 +1563,7 @@ TypeIndex CodeViewDebug::lowerCompleteTy
>> return UnionTI;
>> }
>>
>> -std::tuple<TypeIndex, TypeIndex, unsigned>
>> +std::tuple<TypeIndex, TypeIndex, unsigned, bool>
>> 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
>> @@ -1645,8 +1658,17 @@ CodeViewDebug::lowerRecordFieldList(cons
>> OverloadedMethodRecord(Methods.size(), MethodList, Name));
>> }
>> }
>> +
>> + // Create nested classes.
>> + for (const DICompositeType *Nested : Info.NestedClasses) {
>> + NestedTypeRecord R(getTypeIndex(DITypeRef(Nested)),
>> Nested->getName());
>> + Fields.writeNestedType(R);
>> + MemberCount++;
>> + }
>> +
>> TypeIndex FieldTI = TypeTable.writeFieldList(Fields);
>> - return std::make_tuple(FieldTI, TypeIndex(), MemberCount);
>> + return std::make_tuple(FieldTI, TypeIndex(), MemberCount,
>> + !Info.NestedClasses.empty());
>> }
>>
>> TypeIndex CodeViewDebug::getVBPTypeIndex() {
>>
>> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h?rev=274661&r1=274660&r2=274661&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h (original)
>> +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h Wed Jul 6 14:49:51
>> 2016
>> @@ -275,7 +275,7 @@ class LLVM_LIBRARY_VISIBILITY CodeViewDe
>> /// Common record member lowering functionality for record types,
>> which are
>> /// structs, classes, and unions. Returns the field list index and the
>> member
>> /// count.
>> - std::tuple<codeview::TypeIndex, codeview::TypeIndex, unsigned>
>> + std::tuple<codeview::TypeIndex, codeview::TypeIndex, unsigned, bool>
>> lowerRecordFieldList(const DICompositeType *Ty);
>>
>> /// Inserts {{Node, ClassTy}, TI} into TypeIndices and checks for
>> duplicates.
>>
>> Added: llvm/trunk/test/DebugInfo/COFF/types-nested-class.ll
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/types-nested-class.ll?rev=274661&view=auto
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/COFF/types-nested-class.ll (added)
>> +++ llvm/trunk/test/DebugInfo/COFF/types-nested-class.ll Wed Jul 6
>> 14:49:51 2016
>> @@ -0,0 +1,98 @@
>> +; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
>> +
>> +; C++ source to regenerate:
>> +; $ cat hello.cpp
>> +; struct A {
>> +; struct Nested {};
>> +; } a;
>> +; $ clang hello.cpp -S -emit-llvm -g -gcodeview -o t.ll
>> +
>> +; CHECK: CodeViewTypes [
>> +; CHECK: Section: .debug$T (5)
>> +; CHECK: Magic: 0x4
>> +; CHECK: Struct (0x1000) {
>> +; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
>> +; CHECK: MemberCount: 0
>> +; CHECK: Properties [ (0x280)
>> +; CHECK: ForwardReference (0x80)
>> +; CHECK: HasUniqueName (0x200)
>> +; CHECK: ]
>> +; CHECK: FieldList: 0x0
>> +; CHECK: DerivedFrom: 0x0
>> +; CHECK: VShape: 0x0
>> +; CHECK: SizeOf: 0
>> +; CHECK: Name: A
>> +; CHECK: LinkageName: .?AUA@@
>> +; CHECK: }
>> +; CHECK: Struct (0x1001) {
>> +; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
>> +; CHECK: MemberCount: 0
>> +; CHECK: Properties [ (0x288)
>> +; CHECK: ForwardReference (0x80)
>> +; CHECK: HasUniqueName (0x200)
>> +; CHECK: ]
>> +; CHECK: FieldList: 0x0
>> +; CHECK: DerivedFrom: 0x0
>> +; CHECK: VShape: 0x0
>> +; CHECK: SizeOf: 0
>> +; CHECK: Name: A::Nested
>> +; CHECK: LinkageName: .?AUNested at A@@
>> +; CHECK: }
>> +; CHECK: FieldList (0x1002) {
>> +; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
>> +; CHECK: NestedType {
>> +; CHECK: Type: A::Nested (0x1001)
>> +; CHECK: Name: Nested
>> +; CHECK: }
>> +; CHECK: }
>> +; CHECK: Struct (0x1003) {
>> +; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
>> +; CHECK: MemberCount: 1
>> +; CHECK: Properties [ (0x210)
>> +; CHECK: ContainsNestedClass (0x10)
>> +; CHECK: HasUniqueName (0x200)
>> +; CHECK: ]
>> +; CHECK: FieldList: <field list> (0x1002)
>> +; CHECK: DerivedFrom: 0x0
>> +; CHECK: VShape: 0x0
>> +; CHECK: SizeOf: 1
>> +; CHECK: Name: A
>> +; CHECK: LinkageName: .?AUA@@
>> +; CHECK: }
>> +; CHECK: StringId (0x1004) {
>> +; CHECK: TypeLeafKind: LF_STRING_ID (0x1605)
>> +; CHECK: Id: 0x0
>> +; CHECK: StringData: D:\src\hello\hello.cpp
>> +; CHECK: }
>> +; CHECK: UdtSourceLine (0x1005) {
>> +; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
>> +; CHECK: UDT: A (0x1003)
>> +; CHECK: SourceFile: D:\src\hello\hello.cpp (0x1004)
>> +; CHECK: LineNumber: 1
>> +; CHECK: }
>> +; CHECK: ]
>> +
>> +; ModuleID = 'hello.cpp'
>> +source_filename = "hello.cpp"
>> +target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
>> +target triple = "i686-pc-windows-msvc19.0.23918"
>> +
>> +%struct.A = type { i8 }
>> +
>> +@"\01?a@@3UA@@A" = global %struct.A zeroinitializer, align 1
>> +
>> +!llvm.dbg.cu = !{!0}
>> +!llvm.module.flags = !{!8, !9}
>> +!llvm.ident = !{!10}
>> +
>> +!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, globals: !3)
>> +!1 = !DIFile(filename: "hello.cpp", directory: "D:\5Csrc\5Chello")
>> +!2 = !{}
>> +!3 = !{!4}
>> +!4 = distinct !DIGlobalVariable(name: "a", linkageName: "\01?a@@3UA@@A",
>> scope: !0, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true,
>> variable: %struct.A* @"\01?a@@3UA@@A")
>> +!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A",
>> file: !1, line: 1, size: 8, align: 8, elements: !6, identifier: ".?AUA@
>> @")
>> +!6 = !{!7}
>> +!7 = !DICompositeType(tag: DW_TAG_structure_type, name: "Nested", scope:
>> !5, file: !1, line: 2, size: 8, align: 8, flags: DIFlagFwdDecl, identifier:
>> ".?AUNested at A@@")
>> +!8 = !{i32 2, !"CodeView", i32 1}
>> +!9 = !{i32 2, !"Debug Info Version", i32 3}
>> +!10 = !{!"clang version 3.9.0 "}
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160708/95142de5/attachment.html>
More information about the llvm-commits
mailing list