1 ; RUN: llc -filetype=obj < %s > %t.obj
2 ; RUN: obj2yaml %t.obj | FileCheck %s --check-prefix=YAML
3 ; RUN: llc -filetype=asm < %s | FileCheck %s --check-prefix=ASM
5 ; C++ source to regenerate:
8 ; Foo(int x, int y) : X(x), Y(y) {}
9 ; int method() { return X + Y; }
13 ; int main(int argc, char **argv) {
17 ; $ clang-cc1 -triple i686-pc-windows-msvc19.11.25547 -emit-llvm -gcodeview \
18 ; -debug-info-kind=limited -std=c++14 foo.cpp
22 ; ModuleID = 'foo.cpp'
23 source_filename = "foo.cpp"
24 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
25 target triple = "i686-pc-windows-msvc19.11.25547"
27 %struct.Foo = type { i32, i32 }
29 $"\01??0Foo@@QAE@HH@Z" = comdat any
31 $"\01?method@Foo@@QAEHXZ" = comdat any
33 ; Function Attrs: noinline norecurse nounwind optnone
34 define i32 @main(i32 %argc, i8** %argv) #0 !dbg !8 {
36 %retval = alloca i32, align 4
37 %argv.addr = alloca i8**, align 4
38 %argc.addr = alloca i32, align 4
39 %F = alloca %struct.Foo, align 4
40 store i32 0, i32* %retval, align 4
41 store i8** %argv, i8*** %argv.addr, align 4
42 call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !16, metadata !DIExpression()), !dbg !17
43 store i32 %argc, i32* %argc.addr, align 4
44 call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !18, metadata !DIExpression()), !dbg !17
45 call void @llvm.dbg.declare(metadata %struct.Foo* %F, metadata !19, metadata !DIExpression()), !dbg !31
46 %0 = load i32, i32* %argc.addr, align 4, !dbg !31
47 %1 = load i32, i32* %argc.addr, align 4, !dbg !31
48 %call = call x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@HH@Z"(%struct.Foo* %F, i32 %0, i32 %1), !dbg !31
49 %call1 = call x86_thiscallcc i32 @"\01?method@Foo@@QAEHXZ"(%struct.Foo* %F), !dbg !32
50 ret i32 %call1, !dbg !32
53 ; Function Attrs: nounwind readnone speculatable
54 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
56 ; Function Attrs: noinline nounwind optnone
57 define linkonce_odr x86_thiscallcc %struct.Foo* @"\01??0Foo@@QAE@HH@Z"(%struct.Foo* returned %this, i32 %x, i32 %y) unnamed_addr #2 comdat align 2 !dbg !33 {
59 %y.addr = alloca i32, align 4
60 %x.addr = alloca i32, align 4
61 %this.addr = alloca %struct.Foo*, align 4
62 store i32 %y, i32* %y.addr, align 4
63 call void @llvm.dbg.declare(metadata i32* %y.addr, metadata !34, metadata !DIExpression()), !dbg !35
64 store i32 %x, i32* %x.addr, align 4
65 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !36, metadata !DIExpression()), !dbg !35
66 store %struct.Foo* %this, %struct.Foo** %this.addr, align 4
67 call void @llvm.dbg.declare(metadata %struct.Foo** %this.addr, metadata !37, metadata !DIExpression()), !dbg !39
68 %this1 = load %struct.Foo*, %struct.Foo** %this.addr, align 4
69 %X = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 0, !dbg !35
70 %0 = load i32, i32* %x.addr, align 4, !dbg !35
71 store i32 %0, i32* %X, align 4, !dbg !35
72 %Y = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 1, !dbg !35
73 %1 = load i32, i32* %y.addr, align 4, !dbg !35
74 store i32 %1, i32* %Y, align 4, !dbg !35
75 ret %struct.Foo* %this1, !dbg !35
78 ; Function Attrs: noinline nounwind optnone
79 define linkonce_odr x86_thiscallcc i32 @"\01?method@Foo@@QAEHXZ"(%struct.Foo* %this) #2 comdat align 2 !dbg !40 {
81 %this.addr = alloca %struct.Foo*, align 4
82 store %struct.Foo* %this, %struct.Foo** %this.addr, align 4
83 call void @llvm.dbg.declare(metadata %struct.Foo** %this.addr, metadata !41, metadata !DIExpression()), !dbg !42
84 %this1 = load %struct.Foo*, %struct.Foo** %this.addr, align 4
85 %X = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 0, !dbg !43
86 %0 = load i32, i32* %X, align 4, !dbg !43
87 %Y = getelementptr inbounds %struct.Foo, %struct.Foo* %this1, i32 0, i32 1, !dbg !43
88 %1 = load i32, i32* %Y, align 4, !dbg !43
89 %add = add nsw i32 %0, %1, !dbg !43
90 ret i32 %add, !dbg !43
93 attributes #0 = { noinline norecurse nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
94 attributes #1 = { nounwind readnone speculatable }
95 attributes #2 = { noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
98 !llvm.module.flags = !{!3, !4, !5, !6, !100}
102 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
103 !1 = !DIFile(filename: "<stdin>", directory: "D:\5Csrc\5Cllvmbuild\5Cclang\5CDebug\5Cx86", checksumkind: CSK_MD5, checksum: "6279449503d9075c38e615e8387667c3")
105 !3 = !{i32 1, !"NumRegisterParameters", i32 0}
106 !4 = !{i32 2, !"CodeView", i32 1}
107 !100 = !{i32 2, !"CodeViewGHash", i32 1}
108 !5 = !{i32 2, !"Debug Info Version", i32 3}
109 !6 = !{i32 1, !"wchar_size", i32 2}
110 !7 = !{!"clang version 6.0.0 "}
111 !8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 8, type: !10, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
112 !9 = !DIFile(filename: "foo.cpp", directory: "D:\5Csrc\5Cllvmbuild\5Cclang\5CDebug\5Cx86", checksumkind: CSK_MD5, checksum: "6279449503d9075c38e615e8387667c3")
113 !10 = !DISubroutineType(types: !11)
114 !11 = !{!12, !12, !13}
115 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
116 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)
117 !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 32)
118 !15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
119 !16 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 8, type: !13)
120 !17 = !DILocation(line: 8, scope: !8)
121 !18 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 8, type: !12)
122 !19 = !DILocalVariable(name: "F", scope: !8, file: !9, line: 9, type: !20)
123 !20 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", file: !9, line: 1, size: 64, elements: !21, identifier: ".?AUFoo@@")
124 !21 = !{!22, !23, !24, !28}
125 !22 = !DIDerivedType(tag: DW_TAG_member, name: "X", scope: !20, file: !9, line: 4, baseType: !12, size: 32)
126 !23 = !DIDerivedType(tag: DW_TAG_member, name: "Y", scope: !20, file: !9, line: 5, baseType: !12, size: 32, offset: 32)
127 !24 = !DISubprogram(name: "Foo", scope: !20, file: !9, line: 2, type: !25, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
128 !25 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !26)
129 !26 = !{null, !27, !12, !12}
130 !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer)
131 !28 = !DISubprogram(name: "method", linkageName: "\01?method@Foo@@QAEHXZ", scope: !20, file: !9, line: 3, type: !29, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false)
132 !29 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !30)
134 !31 = !DILocation(line: 9, scope: !8)
135 !32 = !DILocation(line: 10, scope: !8)
136 !33 = distinct !DISubprogram(name: "Foo", linkageName: "\01??0Foo@@QAE@HH@Z", scope: !20, file: !9, line: 2, type: !25, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !24, retainedNodes: !2)
137 !34 = !DILocalVariable(name: "y", arg: 3, scope: !33, file: !9, line: 2, type: !12)
138 !35 = !DILocation(line: 2, scope: !33)
139 !36 = !DILocalVariable(name: "x", arg: 2, scope: !33, file: !9, line: 2, type: !12)
140 !37 = !DILocalVariable(name: "this", arg: 1, scope: !33, type: !38, flags: DIFlagArtificial | DIFlagObjectPointer)
141 !38 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !20, size: 32)
142 !39 = !DILocation(line: 0, scope: !33)
143 !40 = distinct !DISubprogram(name: "method", linkageName: "\01?method@Foo@@QAEHXZ", scope: !20, file: !9, line: 3, type: !29, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !28, retainedNodes: !2)
144 !41 = !DILocalVariable(name: "this", arg: 1, scope: !40, type: !38, flags: DIFlagArtificial | DIFlagObjectPointer)
145 !42 = !DILocation(line: 0, scope: !40)
146 !43 = !DILocation(line: 3, scope: !40)
151 ; YAML: Machine: IMAGE_FILE_MACHINE_I386
152 ; YAML: Characteristics: [ ]
154 ; YAML: - Name: '.debug$T'
155 ; YAML: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
158 ; YAML: - Kind: LF_POINTER
160 ; YAML: ReferentType: 1136
162 ; YAML: - Kind: LF_ARGLIST
164 ; YAML: ArgIndices: [ 116, 4096 ]
165 ; YAML: - Kind: LF_PROCEDURE
167 ; YAML: ReturnType: 116
168 ; YAML: CallConv: NearC
169 ; YAML: Options: [ None ]
170 ; YAML: ParameterCount: 2
171 ; YAML: ArgumentList: 4097
172 ; YAML: - Kind: LF_FUNC_ID
174 ; YAML: ParentScope: 0
175 ; YAML: FunctionType: 4098
177 ; YAML: - Kind: LF_STRUCTURE
179 ; YAML: MemberCount: 0
180 ; YAML: Options: [ None, ForwardReference, HasUniqueName ]
183 ; YAML: UniqueName: '.?AUFoo@@'
184 ; YAML: DerivationList: 0
185 ; YAML: VTableShape: 0
187 ; YAML: - Kind: LF_POINTER
189 ; YAML: ReferentType: 4100
191 ; YAML: - Kind: LF_ARGLIST
193 ; YAML: ArgIndices: [ 116, 116 ]
194 ; YAML: - Kind: LF_MFUNCTION
195 ; YAML: MemberFunction:
196 ; YAML: ReturnType: 3
197 ; YAML: ClassType: 4100
198 ; YAML: ThisType: 4101
199 ; YAML: CallConv: ThisCall
200 ; YAML: Options: [ None ]
201 ; YAML: ParameterCount: 2
202 ; YAML: ArgumentList: 4102
203 ; YAML: ThisPointerAdjustment: 0
204 ; YAML: - Kind: LF_ARGLIST
206 ; YAML: ArgIndices: [ ]
207 ; YAML: - Kind: LF_MFUNCTION
208 ; YAML: MemberFunction:
209 ; YAML: ReturnType: 116
210 ; YAML: ClassType: 4100
211 ; YAML: ThisType: 4101
212 ; YAML: CallConv: ThisCall
213 ; YAML: Options: [ None ]
214 ; YAML: ParameterCount: 0
215 ; YAML: ArgumentList: 4104
216 ; YAML: ThisPointerAdjustment: 0
217 ; YAML: - Kind: LF_FIELDLIST
219 ; YAML: - Kind: LF_MEMBER
223 ; YAML: FieldOffset: 0
225 ; YAML: - Kind: LF_MEMBER
229 ; YAML: FieldOffset: 4
231 ; YAML: - Kind: LF_ONEMETHOD
235 ; YAML: VFTableOffset: -1
237 ; YAML: - Kind: LF_ONEMETHOD
241 ; YAML: VFTableOffset: -1
243 ; YAML: - Kind: LF_STRUCTURE
245 ; YAML: MemberCount: 4
246 ; YAML: Options: [ None, HasUniqueName ]
247 ; YAML: FieldList: 4106
249 ; YAML: UniqueName: '.?AUFoo@@'
250 ; YAML: DerivationList: 0
251 ; YAML: VTableShape: 0
253 ; YAML: - Kind: LF_STRING_ID
256 ; YAML: String: 'D:\src\llvmbuild\clang\Debug\x86\foo.cpp'
257 ; YAML: - Kind: LF_UDT_SRC_LINE
258 ; YAML: UdtSourceLine:
260 ; YAML: SourceFile: 4108
261 ; YAML: LineNumber: 1
262 ; YAML: - Kind: LF_MFUNC_ID
263 ; YAML: MemberFuncId:
264 ; YAML: ClassType: 4100
265 ; YAML: FunctionType: 4103
267 ; YAML: - Kind: LF_MFUNC_ID
268 ; YAML: MemberFuncId:
269 ; YAML: ClassType: 4100
270 ; YAML: FunctionType: 4105
272 ; YAML: - Name: '.debug$H'
273 ; YAML: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
275 ; YAML: GlobalHashes:
277 ; YAML: HashAlgorithm: 1
279 ; YAML: - 800309EE1ED8BB5B
280 ; YAML: - 5397319F1CC14E2C
281 ; YAML: - DF04AA3125BBC50E
282 ; YAML: - 95CEBA304A2C4493
283 ; YAML: - C324F82D24D22283
284 ; YAML: - BB039258F2425BCF
285 ; YAML: - DDE23757322DB7C3
286 ; YAML: - 44D3ED149C981B2A
287 ; YAML: - D341E2F9BE57A1C7
288 ; YAML: - DD327744BE6783A4
289 ; YAML: - 5B17837C70325869
290 ; YAML: - 375C55CDF44B4147
291 ; YAML: - 0634944401BCC520
292 ; YAML: - 6CC0AFB95FA2BFF2
293 ; YAML: - D016F92E5C009314
294 ; YAML: - 74698BE366891D3D
295 ; YAML: - 4470750F2E319329
296 ; YAML: - 0FB556FD1FAB66D7
297 ; YAML: - 5970EFB4874D0F3F
298 ; YAML: - EDB1D74C120CF44A
302 ; ASM: .section .debug$H,"dr"
303 ; ASM-NEXT: .p2align 2
304 ; ASM-NEXT: .long 20171205 # Magic
305 ; ASM-NEXT: .short 0 # Section Version
306 ; ASM-NEXT: .short 1 # Hash Algorithm
307 ; ASM-NEXT: .byte 0x80, 0x03, 0x09, 0xee # 0x1000 [800309EE1ED8BB5B]
308 ; ASM-NEXT: .byte 0x1e, 0xd8, 0xbb, 0x5b
309 ; ASM-NEXT: .byte 0x53, 0x97, 0x31, 0x9f # 0x1001 [5397319F1CC14E2C]
310 ; ASM-NEXT: .byte 0x1c, 0xc1, 0x4e, 0x2c
311 ; ASM-NEXT: .byte 0xdf, 0x04, 0xaa, 0x31 # 0x1002 [DF04AA3125BBC50E]