[llvm] r302085 - DebugInfo: elide type index entries for synthetic types

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 15:13:22 PDT 2017


This isn't what MSVC does for their internal types, but it's probably OK
for now. This is what they do:

  Enum (0x1002) {
    TypeLeafKind: LF_ENUM (0x1507)
    NumEnumerators: 6
    Properties [ (0x208)
      HasUniqueName (0x200)
      Nested (0x8)
    ]
    UnderlyingType: int (0x74)
    FieldListType: <field list> (0x1001)
    Name: __vc_attributes::moduleAttribute::type_e
    LinkageName: .?AW4type_e at moduleAttribute@__vc_attributes@@
  }
  StringId (0x1003) {
    TypeLeafKind: LF_STRING_ID (0x1605)
    Id: 0x0
    StringData: c:\src\llvm-project\build\predefined c++ attributes
(compiler internal)
  }
  UdtSourceLine (0x1004) {
    TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
    UDT: __vc_attributes::moduleAttribute::type_e (0x1002)
    SourceFile: c:\src\llvm-project\build\predefined c++ attributes
(compiler internal) (0x1003)
    LineNumber: 482
  }

Inventing a file and line for __block_descriptor doesn't seem important,
unless we discover some invariant in their debugger that requires one.

On Wed, May 3, 2017 at 2:39 PM, Saleem Abdulrasool via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: compnerd
> Date: Wed May  3 16:39:01 2017
> New Revision: 302085
>
> URL: http://llvm.org/viewvc/llvm-project?rev=302085&view=rev
> Log:
> DebugInfo: elide type index entries for synthetic types
>
> Compiler emitted synthetic types may not have an associated DIFile
> (translation unit).  In such a case, when generating CodeView debug type
> information, we would attempt to compute an absolute filepath which
> would result in a segfault due to a NULL DIFile*.  If there is no source
> file associated with the type, elide the type index entry for the type
> and record the type information.  This actually results in higher
> fidelity debug information than clang/C2 as of this writing.
>
> Resolves PR32668!
>
> Added:
>     llvm/trunk/test/DebugInfo/COFF/synthetic.ll
> Modified:
>     llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=302085&
> r1=302084&r2=302085&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed May  3
> 16:39:01 2017
> @@ -1705,10 +1705,12 @@ TypeIndex CodeViewDebug::lowerCompleteTy
>                   SizeInBytes, FullName, Ty->getIdentifier());
>    TypeIndex ClassTI = TypeTable.writeKnownType(CR);
>
> -  StringIdRecord SIDR(TypeIndex(0x0), getFullFilepath(Ty->getFile()));
> -  TypeIndex SIDI = TypeTable.writeKnownType(SIDR);
> -  UdtSourceLineRecord USLR(ClassTI, SIDI, Ty->getLine());
> -  TypeTable.writeKnownType(USLR);
> +  if (const auto *File = Ty->getFile()) {
> +    StringIdRecord SIDR(TypeIndex(0x0), getFullFilepath(File));
> +    TypeIndex SIDI = TypeTable.writeKnownType(SIDR);
> +    UdtSourceLineRecord USLR(ClassTI, SIDI, Ty->getLine());
> +    TypeTable.writeKnownType(USLR);
> +  }
>
>    addToUDTs(Ty, ClassTI);
>
>
> Added: llvm/trunk/test/DebugInfo/COFF/synthetic.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> DebugInfo/COFF/synthetic.ll?rev=302085&view=auto
> ============================================================
> ==================
> --- llvm/trunk/test/DebugInfo/COFF/synthetic.ll (added)
> +++ llvm/trunk/test/DebugInfo/COFF/synthetic.ll Wed May  3 16:39:01 2017
> @@ -0,0 +1,55 @@
> +; RUN: llc -mtriple x86_64-unknown-windows-msvc -filetype asm -o - %s |
> FileCheck %s
> +
> +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
> +target triple = "x86_64-unknown-windows-msvc"
> +
> +define dllexport void ()* @f() !dbg !6 {
> +entry:
> +  ret void ()* null, !dbg !28
> +}
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!3, !4}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer:
> "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug,
> enums: !2)
> +!1 = !DIFile(filename: "<stdin>", directory:
> "/Users/compnerd/Source/llvm", checksumkind: CSK_MD5, checksum: "
> 2851eea4f12e754f1a68c47a7045406a")
> +!2 = !{}
> +!3 = !{i32 2, !"CodeView", i32 1}
> +!4 = !{i32 2, !"Debug Info Version", i32 3}
> +!6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
> type: !7, isLocal: false, isDefinition: true, scopeLine: 1, flags:
> DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
> +!7 = !DISubroutineType(types: !8)
> +!8 = !{!9}
> +!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)
> +!10 = !DICompositeType(tag: DW_TAG_structure_type, scope: !1, size: 256,
> flags: DIFlagAppleBlock, elements: !11)
> +!11 = !{!12, !14, !16, !17, !21}
> +!12 = !DIDerivedType(tag: DW_TAG_member, name: "__isa", scope: !1, file:
> !1, baseType: !13, size: 64)
> +!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
> +!14 = !DIDerivedType(tag: DW_TAG_member, name: "__flags", scope: !1,
> file: !1, baseType: !15, size: 32, offset: 64)
> +!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
> +!16 = !DIDerivedType(tag: DW_TAG_member, name: "__reserved", scope: !1,
> file: !1, baseType: !15, size: 32, offset: 96)
> +!17 = !DIDerivedType(tag: DW_TAG_member, name: "__FuncPtr", scope: !1,
> file: !1, baseType: !18, size: 64, offset: 128)
> +!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64)
> +!19 = !DISubroutineType(types: !20)
> +!20 = !{null}
> +!21 = !DIDerivedType(tag: DW_TAG_member, name: "__descriptor", scope: !1,
> baseType: !22, size: 64, align: 64, offset: 192)
> +!22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64)
> +!23 = !DICompositeType(tag: DW_TAG_structure_type, name:
> "__block_descriptor", scope: !1, size: 64, flags: DIFlagAppleBlock,
> elements: !24)
> +!24 = !{!25, !27}
> +!25 = !DIDerivedType(tag: DW_TAG_member, name: "reserved", scope: !1,
> file: !1, baseType: !26, size: 32)
> +!26 = !DIBasicType(name: "long unsigned int", size: 32, encoding:
> DW_ATE_unsigned)
> +!27 = !DIDerivedType(tag: DW_TAG_member, name: "Size", scope: !1, file:
> !1, baseType: !26, size: 32, offset: 32)
> +!28 = !DILocation(line: 1, scope: !6)
> +
> +; CHECK: # Struct
> +; CHECK: #   TypeLeafKind: LF_STRUCTURE
> +; CHECK: #   MemberCount: 0
> +; CHECK: #   Properties [
> +; CHECK: #     ForwardReference
> +; CHECK: #   ]
> +; CHECK: #   FieldList: 0x0
> +; CHECK: #   DerivedFrom: 0x0
> +; CHECK: #   VShape: 0x0
> +; CHECK: #   SizeOf: 0
> +; CHECK: #   Name: __block_descriptor
> +; CHECK: # }
> +
>
>
> _______________________________________________
> 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/20170503/60020478/attachment.html>


More information about the llvm-commits mailing list