Index: llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp =================================================================== --- llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp +++ llvm/lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp @@ -58,7 +58,7 @@ 8, // LF_UQUADWORD }; - return Sizes[N - LF_NUMERIC]; + return 2 + Sizes[N - LF_NUMERIC]; } static inline uint32_t getCStringLength(ArrayRef Data) { @@ -393,7 +393,7 @@ Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type break; case SymbolKind::S_REGISTER: - Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type; + Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type break; case SymbolKind::S_CONSTANT: Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type Index: test/DebugInfo/COFF/enum_var.ll =================================================================== --- test/DebugInfo/COFF/enum_var.ll +++ test/DebugInfo/COFF/enum_var.ll @@ -0,0 +1,76 @@ +; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s + +; // enum.cpp +; enum E : unsigned long long { BLAH = -1, BLAH_2 = 0x123456789ABC, BLAH_3 = 1, BLAH_4 = 0xABCDEF }; +; E e; +; // compile with: clang++.exe enum.cpp -c -g -gcodeview -emit-llvm -S + +; CHECK: CodeViewTypes [ +; CHECK: FieldList (0x1000) { +; CHECK-NEXT: TypeLeafKind: LF_FIELDLIST (0x1203) +; CHECK-NEXT: Enumerator { +; CHECK-NEXT: TypeLeafKind: LF_ENUMERATE (0x1502) +; CHECK-NEXT: AccessSpecifier: Public (0x3) +; CHECK-NEXT: EnumValue: 18446744073709551615 +; CHECK-NEXT: Name: BLAH +; CHECK-NEXT: } +; CHECK-NEXT: Enumerator { +; CHECK-NEXT: TypeLeafKind: LF_ENUMERATE (0x1502) +; CHECK-NEXT: AccessSpecifier: Public (0x3) +; CHECK-NEXT: EnumValue: 20015998343868 +; CHECK-NEXT: Name: BLAH_2 +; CHECK-NEXT: } +; CHECK-NEXT: Enumerator { +; CHECK-NEXT: TypeLeafKind: LF_ENUMERATE (0x1502) +; CHECK-NEXT: AccessSpecifier: Public (0x3) +; CHECK-NEXT: EnumValue: 1 +; CHECK-NEXT: Name: BLAH_3 +; CHECK-NEXT: } +; CHECK-NEXT: Enumerator { +; CHECK-NEXT: TypeLeafKind: LF_ENUMERATE (0x1502) +; CHECK-NEXT: AccessSpecifier: Public (0x3) +; CHECK-NEXT: EnumValue: 11259375 +; CHECK-NEXT: Name: BLAH_4 +; CHECK-NEXT: } +; CHECK-NEXT: } +; CHECK-NEXT: Enum (0x1001) { +; CHECK-NEXT: TypeLeafKind: LF_ENUM (0x1507) +; CHECK-NEXT: NumEnumerators: 4 +; CHECK-NEXT: Properties [ (0x200) +; CHECK-NEXT: HasUniqueName (0x200) +; CHECK-NEXT: ] +; CHECK-NEXT: UnderlyingType: unsigned __int64 (0x23) +; CHECK-NEXT: FieldListType: (0x1000) +; CHECK-NEXT: Name: E +; CHECK-NEXT: LinkageName: .?AW4E@@ +; CHECK-NEXT: } + +; ModuleID = 'enum.cpp' +source_filename = "enum.cpp" +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.0.24215" + +@"?e@@3W4E@@A" = dso_local global i64 0, align 8, !dbg !0 + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!13, !14, !15, !16} +!llvm.ident = !{!17} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "e", linkageName: "?e@@3W4E@@A", scope: !2, file: !3, line: 2, type: !5, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 (trunk 328567)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !12) +!3 = !DIFile(filename: "enum.cpp", directory: "F:\5Csvn\5Cllvm\5Ctest\5CDebugInfo\5CCOFF\5Ctest_enum", checksumkind: CSK_MD5, checksum: "05f78dfb7eedd016656ccbc2da244c0f") +!4 = !{!5} +!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E", file: !3, line: 1, baseType: !6, size: 64, flags: DIFlagFixedEnum, elements: !7, identifier: ".?AW4E@@") +!6 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned) +!7 = !{!8, !9, !10, !11} +!8 = !DIEnumerator(name: "BLAH", value: 18446744073709551615, isUnsigned: true) +!9 = !DIEnumerator(name: "BLAH_2", value: 20015998343868, isUnsigned: true) +!10 = !DIEnumerator(name: "BLAH_3", value: 1, isUnsigned: true) +!11 = !DIEnumerator(name: "BLAH_4", value: 11259375, isUnsigned: true) +!12 = !{!0} +!13 = !{i32 2, !"CodeView", i32 1} +!14 = !{i32 2, !"Debug Info Version", i32 3} +!15 = !{i32 1, !"wchar_size", i32 2} +!16 = !{i32 7, !"PIC Level", i32 2} +!17 = !{!"clang version 7.0.0 (trunk 328567)"}