xref: /llvm-project/llvm/test/DebugInfo/COFF/pr37492.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc < %s | FileCheck %s
2
3; Original C++ source:
4; struct Bits {
5;   unsigned char b0 : 1;
6;   unsigned char b1 : 1;
7; } bits;
8; const unsigned char *p_const;
9
10; In PR37492, there was an issue in global type hashing where we forgot to
11; consider the prefix portion of a type record when hashing it. This lead to a
12; collision between this LF_BITFIELD and LF_MODIFIER record, so we only emitted
13; one under the assumption that the other was redundant. Check that we emit both.
14
15; CHECK-LABEL: # BitField (0x1001)
16; CHECK-NEXT: .short	0xa                     # Record length
17; CHECK-NEXT: .short	0x1205                  # Record kind: LF_BITFIELD
18; CHECK-NEXT: .long	0x20                    # Type: unsigned char
19; CHECK-NEXT: .byte	0x1                     # BitSize
20; CHECK-NEXT: .byte	0x0                     # BitOffset
21; CHECK-NEXT: .byte	242
22; CHECK-NEXT: .byte	241
23
24; CHECK-LABEL: # Modifier (0x1007)
25; CHECK-NEXT: .short	0xa                     # Record length
26; CHECK-NEXT: .short	0x1001                  # Record kind: LF_MODIFIER
27; CHECK-NEXT: .long	0x20                    # ModifiedType: unsigned char
28; CHECK-NEXT: .short	0x1                     # Modifiers ( Const (0x1) )
29; CHECK-NEXT: .byte	242
30; CHECK-NEXT: .byte	241
31
32; ModuleID = 't.cpp'
33source_filename = "t.cpp"
34target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
35target triple = "x86_64-pc-windows-msvc19.13.26131"
36
37%struct.Bits = type { i8 }
38
39@"?bits@@3UBits@@A" = dso_local global %struct.Bits zeroinitializer, align 1, !dbg !0
40@"?p_const@@3PEBEEB" = dso_local global ptr null, align 8, !dbg !6
41
42!llvm.dbg.cu = !{!2}
43!llvm.module.flags = !{!15, !16, !17, !18}
44!llvm.ident = !{!19}
45
46!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
47!1 = distinct !DIGlobalVariable(name: "bits", linkageName: "?bits@@3UBits@@A", scope: !2, file: !3, line: 4, type: !11, isLocal: false, isDefinition: true)
48!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 7.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
49!3 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "8910833bbe8b669a3787c8f44dff1313")
50!4 = !{}
51!5 = !{!0, !6}
52!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
53!7 = distinct !DIGlobalVariable(name: "p_const", linkageName: "?p_const@@3PEBEEB", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true)
54!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
55!9 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !10)
56!10 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
57!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Bits", file: !3, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !12, identifier: ".?AUBits@@")
58!12 = !{!13, !14}
59!13 = !DIDerivedType(tag: DW_TAG_member, name: "b0", scope: !11, file: !3, line: 2, baseType: !10, size: 1, flags: DIFlagBitField, extraData: i64 0)
60!14 = !DIDerivedType(tag: DW_TAG_member, name: "b1", scope: !11, file: !3, line: 3, baseType: !10, size: 1, offset: 1, flags: DIFlagBitField, extraData: i64 0)
61!15 = !{i32 2, !"CodeView", i32 1}
62!16 = !{i32 2, !"Debug Info Version", i32 3}
63!17 = !{i32 1, !"wchar_size", i32 2}
64!18 = !{i32 7, !"PIC Level", i32 2}
65!19 = !{!"clang version 7.0.0 "}
66