Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / test / DebugInfo / COFF / globals.ll
blobf26e11c94e9f42f075daa1a19e9692513000af5f
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:
6 ; $ cat t.cpp
7 ; int first;
8 ; template <typename T> struct A { static const int comdat = 3; };
9 ; const int *middle = &A<void>::comdat;
10 ; int last;
11 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
13 ; ASM:        .section        .debug$S,"dr"
14 ; ASM:        .p2align        2
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"
39 ; ASM:        .p2align        2
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
51 ; OBJ:   Magic: 0x4
52 ; OBJ:   Modifier (0x1000) {
53 ; OBJ:     TypeLeafKind: LF_MODIFIER (0x1001)
54 ; OBJ:     ModifiedType: int (0x74)
55 ; OBJ:     Modifiers [ (0x1)
56 ; OBJ:       Const (0x1)
57 ; OBJ:     ]
58 ; OBJ:   }
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)
64 ; OBJ:     IsFlat: 0
65 ; OBJ:     IsConst: 0
66 ; OBJ:     IsVolatile: 0
67 ; OBJ:     IsUnaligned: 0
68 ; OBJ:   }
69 ; OBJ: ]
71 ; OBJ: CodeViewDebugInfo [
72 ; OBJ:   Section: .debug$S
73 ; OBJ:   Magic: 0x4
74 ; OBJ:   Subsection [
75 ; OBJ:     SubSectionType: Symbols (0xF1)
76 ; OBJ:     DataSym {
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
82 ; OBJ:     }
83 ; OBJ:     GlobalTLS {
84 ; OBJ:       DataOffset: ?middle@@3PEBHEB+0x0
85 ; OBJ:       Type: const int* (0x1001)
86 ; OBJ:       DisplayName: middle
87 ; OBJ:       LinkageName: ?middle@@3PEBHEB
88 ; OBJ:     }
89 ; OBJ:     GlobalData {
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
95 ; OBJ:     }
96 ; OBJ:   ]
97 ; OBJ: ]
98 ; OBJ: CodeViewDebugInfo [
99 ; OBJ:   Section: .debug$S
100 ; OBJ:   Magic: 0x4
101 ; OBJ:   Subsection [
102 ; OBJ:     SubSectionType: Symbols (0xF1)
103 ; OBJ:     GlobalData {
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
108 ; OBJ:     }
109 ; OBJ:   ]
110 ; OBJ: ]
112 ; YAML-LABEL:  - Name:            '.debug$S'
113 ; YAML:    Subsections:
114 ; YAML:      - !Symbols
115 ; YAML:        Records:
116 ; YAML:          - Kind:            S_COMPILE3
117 ; YAML:            Compile3Sym:
118 ; YAML:      - !Symbols
119 ; YAML:        Records:
120 ; YAML:          - Kind:            S_LDATA32
121 ; YAML:            DataSym:
122 ; YAML-NOT: Segment
123 ; YAML:              Type:            116
124 ; YAML-NOT: Segment
125 ; YAML:              DisplayName:     first
126 ; YAML-NOT: Segment
127 ; YAML:          - Kind:            S_GTHREAD32
128 ; YAML:            ThreadLocalDataSym:
129 ; YAML:              Type:            4097
130 ; YAML:              DisplayName:     middle
131 ; YAML:          - Kind:            S_GDATA32
132 ; YAML:            DataSym:
133 ; YAML-NOT: Segment
134 ; YAML:              Type:            116
135 ; YAML-NOT: Offset
136 ; YAML-NOT: Segment
137 ; YAML:              DisplayName:     last
138 ; YAML-NOT: Segment
140 ; The missing offsets are represented as relocations against this section.
141 ; YAML:    Relocations:
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
149 ; ModuleID = 't.cpp'
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
161 !llvm.dbg.cu = !{!2}
162 !llvm.module.flags = !{!20, !21, !22}
163 !llvm.ident = !{!23}
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")
169 !4 = !{}
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)
177 !12 = !{!10}
178 !13 = !{!14}
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)"}