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 -filetype=obj | obj2yaml | FileCheck %s --check-prefix=YAML
5 ; C++ source to regenerate:
8 ; template <typename T> struct A { static const int comdat = 3; };
9 ; const int *middle = &A<void>::comdat;
11 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
13 ; ASM: .section .debug$S,"dr"
15 ; ASM: .long 4 # Debug section magic
17 ; ASM: .short {{.*-.*}} # Record length
18 ; ASM: .short 4364 # Record kind: S_LDATA32
19 ; ASM: .long 116 # Type
20 ; ASM: .secrel32 "?first@@3HA" # DataOffset
21 ; ASM: .secidx "?first@@3HA" # Segment
22 ; ASM: .asciz "first" # Name
24 ; ASM: .short {{.*-.*}} # Record length
25 ; ASM: .short 4371 # Record kind: S_GTHREAD32
26 ; ASM: .long 4097 # Type
27 ; ASM: .secrel32 "?middle@@3PEBHEB" # DataOffset
28 ; ASM: .secidx "?middle@@3PEBHEB" # Segment
29 ; ASM: .asciz "middle" # Name
31 ; ASM: .short {{.*-.*}} # Record length
32 ; ASM: .short 4365 # Record kind: S_GDATA32
33 ; ASM: .long 116 # Type
34 ; ASM: .secrel32 "?last@@3HA" # DataOffset
35 ; ASM: .secidx "?last@@3HA" # Segment
36 ; ASM: .asciz "last" # Name
38 ; ASM: .section .debug$S,"dr",associative,"?comdat@?$A@X@@2HB"
40 ; ASM: .long 4 # Debug section magic
42 ; ASM: .short {{.*-.*}} # Record length
43 ; ASM: .short 4365 # Record kind: S_GDATA32
44 ; ASM: .long 4096 # Type
45 ; ASM: .secrel32 "?comdat@?$A@X@@2HB" # DataOffset
46 ; ASM: .secidx "?comdat@?$A@X@@2HB" # Segment
47 ; ASM: .asciz "comdat" # Name
49 ; OBJ: CodeViewTypes [
50 ; OBJ: Section: .debug$T
52 ; OBJ: Modifier (0x1000) {
53 ; OBJ: TypeLeafKind: LF_MODIFIER (0x1001)
54 ; OBJ: ModifiedType: int (0x74)
55 ; OBJ: Modifiers [ (0x1)
59 ; OBJ: Pointer (0x1001) {
60 ; OBJ: TypeLeafKind: LF_POINTER (0x1002)
61 ; OBJ: PointeeType: const int (0x1000)
62 ; OBJ: PtrType: Near64 (0xC)
63 ; OBJ: PtrMode: Pointer (0x0)
71 ; OBJ: CodeViewDebugInfo [
72 ; OBJ: Section: .debug$S
75 ; OBJ: SubSectionType: Symbols (0xF1)
77 ; OBJ: Kind: S_LDATA32 (0x110C)
78 ; OBJ: DataOffset: ?first@@3HA+0x0
79 ; OBJ: Type: int (0x74)
80 ; OBJ: DisplayName: first
81 ; OBJ: LinkageName: ?first@@3HA
84 ; OBJ: DataOffset: ?middle@@3PEBHEB+0x0
85 ; OBJ: Type: const int* (0x1001)
86 ; OBJ: DisplayName: middle
87 ; OBJ: LinkageName: ?middle@@3PEBHEB
90 ; OBJ: Kind: S_GDATA32 (0x110D)
91 ; OBJ: DataOffset: ?last@@3HA+0x0
92 ; OBJ: Type: int (0x74)
93 ; OBJ: DisplayName: last
94 ; OBJ: LinkageName: ?last@@3HA
98 ; OBJ: CodeViewDebugInfo [
99 ; OBJ: Section: .debug$S
102 ; OBJ: SubSectionType: Symbols (0xF1)
104 ; OBJ: DataOffset: ?comdat@?$A@X@@2HB+0x0
105 ; OBJ: Type: const int (0x1000)
106 ; OBJ: DisplayName: comdat
107 ; OBJ: LinkageName: ?comdat@?$A@X@@2HB
112 ; YAML-LABEL: - Name: '.debug$S'
116 ; YAML: - Kind: S_COMPILE3
120 ; YAML: - Kind: S_LDATA32
125 ; YAML: DisplayName: first
127 ; YAML: - Kind: S_GTHREAD32
128 ; YAML: ThreadLocalDataSym:
130 ; YAML: DisplayName: middle
131 ; YAML: - Kind: S_GDATA32
137 ; YAML: DisplayName: last
140 ; The missing offsets are represented as relocations against this section.
142 ; YAML: - VirtualAddress: 92
143 ; YAML: SymbolName: '?first@@3HA'
144 ; YAML: Type: IMAGE_REL_AMD64_SECREL
145 ; YAML: - VirtualAddress: 96
146 ; YAML: SymbolName: '?first@@3HA'
147 ; YAML: Type: IMAGE_REL_AMD64_SECTION
150 source_filename = "t.cpp"
151 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
152 target triple = "x86_64-pc-windows-msvc19.0.23918"
154 $"\01?comdat@?$A@X@@2HB" = comdat any
156 @"\01?first@@3HA" = internal global i32 0, align 4, !dbg !0
157 @"\01?comdat@?$A@X@@2HB" = linkonce_odr constant i32 3, comdat, align 4, !dbg !6
158 @"\01?middle@@3PEBHEB" = thread_local global i32* @"\01?comdat@?$A@X@@2HB", align 8, !dbg !15
159 @"\01?last@@3HA" = global i32 0, align 4, !dbg !18
162 !llvm.module.flags = !{!20, !21, !22}
165 !0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
166 !1 = !DIGlobalVariable(name: "first", linkageName: "\01?first@@3HA", scope: !2, file: !3, line: 1, type: !9, isLocal: true, isDefinition: true)
167 !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)
168 !3 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
170 !5 = !{!0, !6, !15, !18}
171 !6 = distinct !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
172 !7 = !DIGlobalVariable(name: "comdat", linkageName: "\01?comdat@?$A@X@@2HB", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true, declaration: !10)
173 !8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)
174 !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
175 !10 = !DIDerivedType(tag: DW_TAG_member, name: "comdat", scope: !11, file: !3, line: 2, baseType: !8, flags: DIFlagStaticMember, extraData: i32 3)
176 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "A<void>", file: !3, line: 2, size: 8, align: 8, elements: !12, templateParams: !13)
179 !14 = !DITemplateTypeParameter(name: "T", type: null)
180 !15 = distinct !DIGlobalVariableExpression(var: !16, expr: !DIExpression())
181 !16 = !DIGlobalVariable(name: "middle", linkageName: "\01?middle@@3PEBHEB", scope: !2, file: !3, line: 3, type: !17, isLocal: false, isDefinition: true)
182 !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64, align: 64)
183 !18 = distinct !DIGlobalVariableExpression(var: !19, expr: !DIExpression())
184 !19 = !DIGlobalVariable(name: "last", linkageName: "\01?last@@3HA", scope: !2, file: !3, line: 4, type: !9, isLocal: false, isDefinition: true)
185 !20 = !{i32 2, !"CodeView", i32 1}
186 !21 = !{i32 2, !"Debug Info Version", i32 3}
187 !22 = !{i32 1, !"PIC Level", i32 2}
188 !23 = !{!"clang version 3.9.0 (trunk 271937)"}