xref: /llvm-project/llvm/test/DebugInfo/X86/DW_AT_object_pointer.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
2; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
3
4; CHECK: DW_TAG_formal_parameter [
5; CHECK-NOT: ""
6; CHECK: DW_TAG
7; CHECK: DW_TAG_class_type
8; CHECK: DW_AT_object_pointer [DW_FORM_ref4]     (cu + 0x{{[0-9a-f]*}} => {[[PARAM:0x[0-9a-f]*]]})
9; CHECK: [[PARAM]]:     DW_TAG_formal_parameter
10; CHECK-NOT: DW_TAG
11; CHECK: DW_AT_name [DW_FORM_strp]     ( .debug_str[0x{{[0-9a-f]*}}] = "this")
12
13%class.A = type { i32 }
14
15define i32 @_Z3fooi(i32) nounwind uwtable ssp !dbg !5 {
16entry:
17  %.addr = alloca i32, align 4
18  %a = alloca %class.A, align 4
19  store i32 %0, ptr %.addr, align 4
20  call void @llvm.dbg.declare(metadata ptr %.addr, metadata !36, metadata !DIExpression()), !dbg !35
21  call void @llvm.dbg.declare(metadata ptr %a, metadata !21, metadata !DIExpression()), !dbg !23
22  call void @_ZN1AC1Ev(ptr %a), !dbg !24
23  %1 = load i32, ptr %a, align 4, !dbg !25
24  ret i32 %1, !dbg !25
25}
26
27declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
28
29define linkonce_odr void @_ZN1AC1Ev(ptr %this) unnamed_addr nounwind uwtable ssp align 2 !dbg !10 {
30entry:
31  %this.addr = alloca ptr, align 8
32  store ptr %this, ptr %this.addr, align 8
33  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !26, metadata !DIExpression()), !dbg !28
34  %this1 = load ptr, ptr %this.addr
35  call void @_ZN1AC2Ev(ptr %this1), !dbg !29
36  ret void, !dbg !29
37}
38
39define linkonce_odr void @_ZN1AC2Ev(ptr %this) unnamed_addr nounwind uwtable ssp align 2 !dbg !20 {
40entry:
41  %this.addr = alloca ptr, align 8
42  store ptr %this, ptr %this.addr, align 8
43  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !30, metadata !DIExpression()), !dbg !31
44  %this1 = load ptr, ptr %this.addr
45  store i32 0, ptr %this1, align 4, !dbg !32
46  ret void, !dbg !34
47}
48
49!llvm.dbg.cu = !{!0}
50!llvm.module.flags = !{!38}
51
52!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.2 (trunk 163586) (llvm/trunk 163570)", isOptimized: false, emissionKind: FullDebug, file: !37, enums: !1, retainedTypes: !1, globals: !1, imports:  !1)
53!1 = !{}
54!5 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !6, scope: !6, type: !7, retainedNodes: !1)
55!6 = !DIFile(filename: "bar.cpp", directory: "/Users/echristo/debug-tests")
56!7 = !DISubroutineType(types: !8)
57!8 = !{!9}
58!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
59!10 = distinct !DISubprogram(name: "A", linkageName: "_ZN1AC1Ev", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !6, scope: null, type: !11, declaration: !17, retainedNodes: !1)
60!11 = !DISubroutineType(types: !12)
61!12 = !{null, !13}
62!13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !14)
63!14 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 1, size: 32, align: 32, file: !37, elements: !15)
64!15 = !{!16, !17}
65!16 = !DIDerivedType(tag: DW_TAG_member, name: "m_a", line: 4, size: 32, align: 32, file: !37, scope: !14, baseType: !9)
66!17 = !DISubprogram(name: "A", line: 3, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !6, scope: !14, type: !11)
67!20 = distinct !DISubprogram(name: "A", linkageName: "_ZN1AC2Ev", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !6, scope: null, type: !11, declaration: !17, retainedNodes: !1)
68!21 = !DILocalVariable(name: "a", line: 8, scope: !22, file: !6, type: !14)
69!22 = distinct !DILexicalBlock(line: 7, column: 11, file: !6, scope: !5)
70!23 = !DILocation(line: 8, column: 5, scope: !22)
71!24 = !DILocation(line: 8, column: 6, scope: !22)
72!25 = !DILocation(line: 9, column: 3, scope: !22)
73!26 = !DILocalVariable(name: "this", line: 3, arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !10, file: !6, type: !27)
74!27 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !14)
75!28 = !DILocation(line: 3, column: 3, scope: !10)
76!29 = !DILocation(line: 3, column: 18, scope: !10)
77!30 = !DILocalVariable(name: "this", line: 3, arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !20, file: !6, type: !27)
78!31 = !DILocation(line: 3, column: 3, scope: !20)
79!32 = !DILocation(line: 3, column: 9, scope: !33)
80!33 = distinct !DILexicalBlock(line: 3, column: 7, file: !6, scope: !20)
81!34 = !DILocation(line: 3, column: 18, scope: !33)
82!35 = !DILocation(line: 7, scope: !5)
83!36 = !DILocalVariable(name: "", line: 7, arg: 1, scope: !5, file: !6, type: !9)
84!37 = !DIFile(filename: "bar.cpp", directory: "/Users/echristo/debug-tests")
85!38 = !{i32 1, !"Debug Info Version", i32 3}
86