1; RUN: llc < %s | FileCheck %s --check-prefix=ASM
2; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ
3; RUN: llc < %s | llvm-mc -filetype=obj --triple=x86_64-windows | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ
4; RUN: llc < %s -filetype=obj | obj2yaml | FileCheck %s --check-prefix=YAML
5
6; C++ source to regenerate:
7; $ cat t.cpp
8; int first;
9; template <typename T> struct A { static const int comdat = 3; };
10; const int *middle = &A<void>::comdat;
11; int last;
12; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
13
14; ASM:        .section        .debug$S,"dr"
15; ASM:        .p2align        2
16; ASM:        .long   4                       # Debug section magic
17
18; ASM:        .short  {{.*-.*}}               # Record length
19; ASM:        .short  4364                    # Record kind: S_LDATA32
20; ASM:        .long   116                     # Type
21; ASM:        .secrel32       "?first@@3HA"   # DataOffset
22; ASM:        .secidx "?first@@3HA"           # Segment
23; ASM:        .asciz  "first"                 # Name
24
25; ASM:        .short  {{.*-.*}}               # Record length
26; ASM:        .short  4371                    # Record kind: S_GTHREAD32
27; ASM:        .long   4097                    # Type
28; ASM:        .secrel32       "?middle@@3PEBHEB" # DataOffset
29; ASM:        .secidx "?middle@@3PEBHEB"      # Segment
30; ASM:        .asciz  "middle"                # Name
31
32; ASM:        .short  {{.*-.*}}               # Record length
33; ASM:        .short  4365                    # Record kind: S_GDATA32
34; ASM:        .long   116                     # Type
35; ASM:        .secrel32       "?last@@3HA"    # DataOffset
36; ASM:        .secidx "?last@@3HA"            # Segment
37; ASM:        .asciz  "last"                  # Name
38
39; ASM:        .section        .debug$S,"dr",associative,"?comdat@?$A@X@@2HB"
40; ASM:        .p2align        2
41; ASM:        .long   4                       # Debug section magic
42
43; ASM:        .short  {{.*-.*}}               # Record length
44; ASM:        .short  4365                    # Record kind: S_GDATA32
45; ASM:        .long   4096                    # Type
46; ASM:        .secrel32       "?comdat@?$A@X@@2HB" # DataOffset
47; ASM:        .secidx "?comdat@?$A@X@@2HB"    # Segment
48; ASM:        .asciz  "comdat"                # Name
49
50; OBJ: CodeViewTypes [
51; OBJ:   Section: .debug$T
52; OBJ:   Magic: 0x4
53; OBJ:   Modifier (0x1000) {
54; OBJ:     TypeLeafKind: LF_MODIFIER (0x1001)
55; OBJ:     ModifiedType: int (0x74)
56; OBJ:     Modifiers [ (0x1)
57; OBJ:       Const (0x1)
58; OBJ:     ]
59; OBJ:   }
60; OBJ:   Pointer (0x1001) {
61; OBJ:     TypeLeafKind: LF_POINTER (0x1002)
62; OBJ:     PointeeType: const int (0x1000)
63; OBJ:     PtrType: Near64 (0xC)
64; OBJ:     PtrMode: Pointer (0x0)
65; OBJ:     IsFlat: 0
66; OBJ:     IsConst: 0
67; OBJ:     IsVolatile: 0
68; OBJ:     IsUnaligned: 0
69; OBJ:   }
70; OBJ: ]
71
72; OBJ: CodeViewDebugInfo [
73; OBJ:   Section: .debug$S
74; OBJ:   Magic: 0x4
75; OBJ:   Subsection [
76; OBJ:     SubSectionType: Symbols (0xF1)
77; OBJ:     DataSym {
78; OBJ:       Kind: S_LDATA32 (0x110C)
79; OBJ:       DataOffset: ?first@@3HA+0x0
80; OBJ:       Type: int (0x74)
81; OBJ:       DisplayName: first
82; OBJ:       LinkageName: ?first@@3HA
83; OBJ:     }
84; OBJ:     GlobalTLS {
85; OBJ:       DataOffset: ?middle@@3PEBHEB+0x0
86; OBJ:       Type: const int* (0x1001)
87; OBJ:       DisplayName: middle
88; OBJ:       LinkageName: ?middle@@3PEBHEB
89; OBJ:     }
90; OBJ:     GlobalData {
91; OBJ:       Kind: S_GDATA32 (0x110D)
92; OBJ:       DataOffset: ?last@@3HA+0x0
93; OBJ:       Type: int (0x74)
94; OBJ:       DisplayName: last
95; OBJ:       LinkageName: ?last@@3HA
96; OBJ:     }
97; OBJ:   ]
98; OBJ: ]
99; OBJ: CodeViewDebugInfo [
100; OBJ:   Section: .debug$S
101; OBJ:   Magic: 0x4
102; OBJ:   Subsection [
103; OBJ:     SubSectionType: Symbols (0xF1)
104; OBJ:     GlobalData {
105; OBJ:       DataOffset: ?comdat@?$A@X@@2HB+0x0
106; OBJ:       Type: const int (0x1000)
107; OBJ:       DisplayName: comdat
108; OBJ:       LinkageName: ?comdat@?$A@X@@2HB
109; OBJ:     }
110; OBJ:   ]
111; OBJ: ]
112
113; YAML-LABEL:  - Name:            '.debug$S'
114; YAML:    Subsections:
115; YAML:      - !Symbols
116; YAML:        Records:
117; YAML:          - Kind:            S_COMPILE3
118; YAML:            Compile3Sym:
119; YAML:      - !Symbols
120; YAML:        Records:
121; YAML:          - Kind:            S_LDATA32
122; YAML:            DataSym:
123; YAML-NOT: Segment
124; YAML:              Type:            116
125; YAML-NOT: Segment
126; YAML:              DisplayName:     first
127; YAML-NOT: Segment
128; YAML:          - Kind:            S_GTHREAD32
129; YAML:            ThreadLocalDataSym:
130; YAML:              Type:            4097
131; YAML:              DisplayName:     middle
132; YAML:          - Kind:            S_GDATA32
133; YAML:            DataSym:
134; YAML-NOT: Segment
135; YAML:              Type:            116
136; YAML-NOT: Offset
137; YAML-NOT: Segment
138; YAML:              DisplayName:     last
139; YAML-NOT: Segment
140
141; The missing offsets are represented as relocations against this section.
142; YAML:    Relocations:
143; YAML:      - VirtualAddress:  92
144; YAML:        SymbolName:      '?first@@3HA'
145; YAML:        Type:            IMAGE_REL_AMD64_SECREL
146; YAML:      - VirtualAddress:  96
147; YAML:        SymbolName:      '?first@@3HA'
148; YAML:        Type:            IMAGE_REL_AMD64_SECTION
149
150; ModuleID = 't.cpp'
151source_filename = "t.cpp"
152target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
153target triple = "x86_64-pc-windows-msvc19.0.23918"
154
155$"\01?comdat@?$A@X@@2HB" = comdat any
156
157@"\01?first@@3HA" = internal global i32 0, align 4, !dbg !0
158@"\01?comdat@?$A@X@@2HB" = linkonce_odr constant i32 3, comdat, align 4, !dbg !6
159@"\01?middle@@3PEBHEB" = thread_local global i32* @"\01?comdat@?$A@X@@2HB", align 8, !dbg !15
160@"\01?last@@3HA" = global i32 0, align 4, !dbg !18
161
162!llvm.dbg.cu = !{!2}
163!llvm.module.flags = !{!20, !21, !22}
164!llvm.ident = !{!23}
165
166!0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
167!1 = !DIGlobalVariable(name: "first", linkageName: "\01?first@@3HA", scope: !2, file: !3, line: 1, type: !9, isLocal: true, isDefinition: true)
168!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.9.0 (trunk 271937)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
169!3 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
170!4 = !{}
171!5 = !{!0, !6, !15, !18}
172!6 = distinct !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
173!7 = !DIGlobalVariable(name: "comdat", linkageName: "\01?comdat@?$A@X@@2HB", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true, declaration: !10)
174!8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)
175!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
176!10 = !DIDerivedType(tag: DW_TAG_member, name: "comdat", scope: !11, file: !3, line: 2, baseType: !8, flags: DIFlagStaticMember, extraData: i32 3)
177!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A<void>", file: !3, line: 2, size: 8, align: 8, elements: !12, templateParams: !13)
178!12 = !{!10}
179!13 = !{!14}
180!14 = !DITemplateTypeParameter(name: "T", type: null)
181!15 = distinct !DIGlobalVariableExpression(var: !16, expr: !DIExpression())
182!16 = !DIGlobalVariable(name: "middle", linkageName: "\01?middle@@3PEBHEB", scope: !2, file: !3, line: 3, type: !17, isLocal: false, isDefinition: true)
183!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64)
184!18 = distinct !DIGlobalVariableExpression(var: !19, expr: !DIExpression())
185!19 = !DIGlobalVariable(name: "last", linkageName: "\01?last@@3HA", scope: !2, file: !3, line: 4, type: !9, isLocal: false, isDefinition: true)
186!20 = !{i32 2, !"CodeView", i32 1}
187!21 = !{i32 2, !"Debug Info Version", i32 3}
188!22 = !{i32 1, !"PIC Level", i32 2}
189!23 = !{!"clang version 3.9.0 (trunk 271937)"}
190
191