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
6 ; C++ source to regenerate:
9 ; template <typename T> struct A { static const int comdat = 3; };
10 ; const int *middle = &A<void>::comdat;
12 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
14 ; ASM: .section .debug$S,"dr"
16 ; ASM: .long 4 # Debug section magic
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
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
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
39 ; ASM: .section .debug$S,"dr",associative,"?comdat@?$A@X@@2HB"
41 ; ASM: .long 4 # Debug section magic
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
50 ; OBJ: CodeViewTypes [
51 ; OBJ: Section: .debug$T
53 ; OBJ: Modifier (0x1000) {
54 ; OBJ: TypeLeafKind: LF_MODIFIER (0x1001)
55 ; OBJ: ModifiedType: int (0x74)
56 ; OBJ: Modifiers [ (0x1)
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)
72 ; OBJ: CodeViewDebugInfo [
73 ; OBJ: Section: .debug$S
76 ; OBJ: SubSectionType: Symbols (0xF1)
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
85 ; OBJ: DataOffset: ?middle@@3PEBHEB+0x0
86 ; OBJ: Type: const int* (0x1001)
87 ; OBJ: DisplayName: middle
88 ; OBJ: LinkageName: ?middle@@3PEBHEB
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
99 ; OBJ: CodeViewDebugInfo [
100 ; OBJ: Section: .debug$S
103 ; OBJ: SubSectionType: Symbols (0xF1)
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
113 ; YAML-LABEL: - Name: '.debug$S'
117 ; YAML: - Kind: S_COMPILE3
121 ; YAML: - Kind: S_LDATA32
126 ; YAML: DisplayName: first
128 ; YAML: - Kind: S_GTHREAD32
129 ; YAML: ThreadLocalDataSym:
131 ; YAML: DisplayName: middle
132 ; YAML: - Kind: S_GDATA32
138 ; YAML: DisplayName: last
141 ; The missing offsets are represented as relocations against this section.
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
151 source_filename = "t.cpp"
152 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
153 target triple = "x86_64-pc-windows-msvc19.0.23918"
155 $"\01?comdat@?$A@X@@2HB" = comdat any
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
163 !llvm.module.flags = !{!20, !21, !22}
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")
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)
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)"}