xref: /llvm-project/llvm/test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll (revision 391f323690b9ef84d13a09ff07fb805008401fee)
1; RUN: %llc_dwarf -O0 -filetype=obj -o - < %s | llvm-dwarfdump -debug-info - | FileCheck %s
2; Radar 7833483
3; Do not emit a separate out-of-line definition DIE for the function-local 'foo'
4; function (member of the function local 'A' type)
5; CHECK: DW_TAG_class_type
6; CHECK: DW_TAG_class_type
7; CHECK-NEXT: DW_AT_name ("A")
8; Check that the subprogram inside the class definition has low_pc, only
9; attached to the definition.
10; CHECK: [[FOO_INL:0x........]]: DW_TAG_subprogram
11; CHECK-NOT: DW_TAG
12; CHECK: DW_AT_low_pc
13; CHECK-NOT: DW_TAG
14; CHECK: DW_AT_name ("foo")
15; And just double check that there's no out of line definition that references
16; this subprogram.
17; CHECK-NOT: DW_AT_specification ([[FOO_INL]]
18
19%class.A = type { i8 }
20%class.B = type { i8 }
21
22define i32 @main() ssp !dbg !2 {
23entry:
24  %retval = alloca i32, align 4                   ; <ptr> [#uses=3]
25  %b = alloca %class.A, align 1                   ; <ptr> [#uses=1]
26  store i32 0, ptr %retval
27  call void @llvm.dbg.declare(metadata ptr %b, metadata !0, metadata !DIExpression()), !dbg !14
28  %call = call i32 @_ZN1B2fnEv(ptr %b), !dbg !15 ; <i32> [#uses=1]
29  store i32 %call, ptr %retval, !dbg !15
30  %0 = load i32, ptr %retval, !dbg !16                ; <i32> [#uses=1]
31  ret i32 %0, !dbg !16
32}
33
34declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
35
36define linkonce_odr i32 @_ZN1B2fnEv(ptr %this) ssp align 2 !dbg !10 {
37entry:
38  %retval = alloca i32, align 4                   ; <ptr> [#uses=2]
39  %this.addr = alloca ptr, align 8          ; <ptr> [#uses=2]
40  %a = alloca %class.A, align 1                   ; <ptr> [#uses=1]
41  %i = alloca i32, align 4                        ; <ptr> [#uses=2]
42  store ptr %this, ptr %this.addr
43  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !17, metadata !DIExpression(DW_OP_deref)), !dbg !18
44  %this1 = load ptr, ptr %this.addr             ; <ptr> [#uses=0]
45  call void @llvm.dbg.declare(metadata ptr %a, metadata !19, metadata !DIExpression()), !dbg !27
46  call void @llvm.dbg.declare(metadata ptr %i, metadata !28, metadata !DIExpression()), !dbg !29
47  %call = call i32 @_ZZN1B2fnEvEN1A3fooEv(ptr %a), !dbg !30 ; <i32> [#uses=1]
48  store i32 %call, ptr %i, !dbg !30
49  %tmp = load i32, ptr %i, !dbg !31                   ; <i32> [#uses=1]
50  store i32 %tmp, ptr %retval, !dbg !31
51  %0 = load i32, ptr %retval, !dbg !32                ; <i32> [#uses=1]
52  ret i32 %0, !dbg !32
53}
54
55define internal i32 @_ZZN1B2fnEvEN1A3fooEv(ptr %this) ssp align 2 !dbg !23 {
56entry:
57  %retval = alloca i32, align 4                   ; <ptr> [#uses=2]
58  %this.addr = alloca ptr, align 8          ; <ptr> [#uses=2]
59  store ptr %this, ptr %this.addr
60  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !33, metadata !DIExpression(DW_OP_deref)), !dbg !34
61  %this1 = load ptr, ptr %this.addr             ; <ptr> [#uses=0]
62  store i32 42, ptr %retval, !dbg !35
63  %0 = load i32, ptr %retval, !dbg !35                ; <i32> [#uses=1]
64  ret i32 %0, !dbg !35
65}
66
67!llvm.dbg.cu = !{!4}
68!llvm.module.flags = !{!40}
69!37 = !{!2, !10, !23}
70
71!0 = !DILocalVariable(name: "b", line: 16, scope: !1, file: !3, type: !8)
72!1 = distinct !DILexicalBlock(line: 15, column: 12, file: !38, scope: !2)
73!2 = distinct !DISubprogram(name: "main", linkageName: "main", line: 15, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !4, scopeLine: 15, file: !38, scope: !3, type: !5)
74!3 = !DIFile(filename: "one.cc", directory: "/tmp")
75!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang 1.5", isOptimized: false, emissionKind: FullDebug, file: !38, enums: !39, retainedTypes: !39, imports:  null)
76!5 = !DISubroutineType(types: !6)
77!6 = !{!7}
78!7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
79!8 = !DICompositeType(tag: DW_TAG_class_type, name: "B", line: 2, size: 8, align: 8, file: !38, scope: !3, elements: !9)
80!9 = !{!10}
81!10 = distinct !DISubprogram(name: "fn", linkageName: "_ZN1B2fnEv", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !4, scopeLine: 4, file: !38, scope: !8, type: !11)
82!11 = !DISubroutineType(types: !12)
83!12 = !{!7, !13}
84!13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial, file: !38, scope: !3, baseType: !8)
85!14 = !DILocation(line: 16, column: 5, scope: !1)
86!15 = !DILocation(line: 17, column: 3, scope: !1)
87!16 = !DILocation(line: 18, column: 1, scope: !2)
88; Manually modified to avoid pointers (thus dependence on pointer size) in Generic test
89!17 = !DILocalVariable(name: "this", line: 4, arg: 1, scope: !10, file: !3, type: !8)
90!18 = !DILocation(line: 4, column: 7, scope: !10)
91!19 = !DILocalVariable(name: "a", line: 9, scope: !20, file: !3, type: !21)
92!20 = distinct !DILexicalBlock(line: 4, column: 12, file: !38, scope: !10)
93!21 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 5, size: 8, align: 8, file: !38, scope: !10, elements: !22)
94!22 = !{!23}
95!23 = distinct !DISubprogram(name: "foo", linkageName: "_ZZN1B2fnEvEN1A3fooEv", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !4, scopeLine: 7, file: !38, scope: !21, type: !24)
96!24 = !DISubroutineType(types: !25)
97!25 = !{!7, !26}
98!26 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial, file: !38, scope: !3, baseType: !21)
99!27 = !DILocation(line: 9, column: 7, scope: !20)
100!28 = !DILocalVariable(name: "i", line: 10, scope: !20, file: !3, type: !7)
101!29 = !DILocation(line: 10, column: 9, scope: !20)
102!30 = !DILocation(line: 10, column: 5, scope: !20)
103!31 = !DILocation(line: 11, column: 5, scope: !20)
104!32 = !DILocation(line: 12, column: 3, scope: !10)
105; Manually modified like !17 above
106!33 = !DILocalVariable(name: "this", line: 7, arg: 1, scope: !23, file: !3, type: !21)
107!34 = !DILocation(line: 7, column: 11, scope: !23)
108!35 = !DILocation(line: 7, column: 19, scope: !36)
109!36 = distinct !DILexicalBlock(line: 7, column: 17, file: !38, scope: !23)
110!38 = !DIFile(filename: "one.cc", directory: "/tmp")
111!39 = !{}
112!40 = !{i32 1, !"Debug Info Version", i32 3}
113