1; For some reason, the output when targetting sparc is not quite as expected.
2; XFAIL: sparc
3
4; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
5
6; IR generated from clang -O0 with:
7; struct C {
8;   ~C();
9; };
10; extern bool b;
11; void fun4() { b && (C(), 1); }
12; __attribute__((always_inline)) C::~C() { }
13
14; CHECK: DW_TAG_structure_type
15; CHECK-NOT: DW_TAG
16; CHECK:   DW_AT_name {{.*}} "C"
17; CHECK-NOT: {{DW_TAG|NULL}}
18; CHECK:   DW_TAG_subprogram
19; CHECK-NOT: DW_TAG
20; CHECK:     DW_AT_name {{.*}} "~C"
21
22; CHECK:  DW_TAG_subprogram
23; CHECK-NOT: DW_TAG
24; CHECK:   DW_AT_linkage_name {{.*}} "_ZN1CD1Ev"
25; CHECK-NOT: {{DW_TAG|NULL}}
26; CHECK:  DW_TAG_formal_parameter
27; CHECK-NOT: DW_TAG
28; CHECK:     DW_AT_name {{.*}} "this"
29
30; CHECK: DW_TAG_subprogram
31; CHECK-NOT: DW_TAG
32; CHECK:   DW_AT_name {{.*}} "fun4"
33; CHECK-NOT: {{DW_TAG|NULL}}
34; CHECK:   DW_TAG_inlined_subroutine
35; CHECK-NOT: DW_TAG
36; CHECK:     DW_AT_abstract_origin {{.*}} "_ZN1CD1Ev"
37; CHECK-NOT: {{DW_TAG|NULL}}
38; CHECK:     DW_TAG_formal_parameter
39; CHECK-NOT: DW_TAG
40; CHECK:       DW_AT_abstract_origin {{.*}} "this"
41
42; FIXME: D2 is actually inlined into D1 but doesn't show up here, possibly due
43; to there being no work in D2 (calling another member function from the dtor
44; causes D2 to show up, calling a free function doesn't).
45
46; CHECK-NOT: DW_TAG
47; CHECK:     NULL
48; CHECK-NOT: DW_TAG
49; CHECK:   NULL
50
51%struct.C = type { i8 }
52
53@b = external global i8
54
55; Function Attrs: nounwind
56define void @_Z4fun4v() #0 !dbg !12 {
57entry:
58  %this.addr.i.i = alloca %struct.C*, align 8, !dbg !21
59  %this.addr.i = alloca %struct.C*, align 8, !dbg !22
60  %agg.tmp.ensured = alloca %struct.C, align 1
61  %cleanup.cond = alloca i1
62  %0 = load i8, i8* @b, align 1, !dbg !24
63  %tobool = trunc i8 %0 to i1, !dbg !24
64  store i1 false, i1* %cleanup.cond
65  br i1 %tobool, label %land.rhs, label %land.end, !dbg !24
66
67land.rhs:                                         ; preds = %entry
68  store i1 true, i1* %cleanup.cond, !dbg !25
69  br label %land.end
70
71land.end:                                         ; preds = %land.rhs, %entry
72  %1 = phi i1 [ false, %entry ], [ true, %land.rhs ]
73  %cleanup.is_active = load i1, i1* %cleanup.cond, !dbg !27
74  br i1 %cleanup.is_active, label %cleanup.action, label %cleanup.done, !dbg !27
75
76cleanup.action:                                   ; preds = %land.end
77  store %struct.C* %agg.tmp.ensured, %struct.C** %this.addr.i, align 8, !dbg !22
78  call void @llvm.dbg.declare(metadata %struct.C** %this.addr.i, metadata !129, metadata !DIExpression()), !dbg !31
79  %this1.i = load %struct.C*, %struct.C** %this.addr.i, !dbg !22
80  store %struct.C* %this1.i, %struct.C** %this.addr.i.i, align 8, !dbg !21
81  call void @llvm.dbg.declare(metadata %struct.C** %this.addr.i.i, metadata !132, metadata !DIExpression()), !dbg !33
82  %this1.i.i = load %struct.C*, %struct.C** %this.addr.i.i, !dbg !21
83  br label %cleanup.done, !dbg !22
84
85cleanup.done:                                     ; preds = %cleanup.action, %land.end
86  ret void, !dbg !34
87}
88
89; Function Attrs: alwaysinline nounwind
90define void @_ZN1CD1Ev(%struct.C* %this) unnamed_addr #1 align 2 !dbg !17 {
91entry:
92  %this.addr.i = alloca %struct.C*, align 8, !dbg !37
93  %this.addr = alloca %struct.C*, align 8
94  store %struct.C* %this, %struct.C** %this.addr, align 8
95  call void @llvm.dbg.declare(metadata %struct.C** %this.addr, metadata !29, metadata !DIExpression()), !dbg !38
96  %this1 = load %struct.C*, %struct.C** %this.addr
97  store %struct.C* %this1, %struct.C** %this.addr.i, align 8, !dbg !37
98  call void @llvm.dbg.declare(metadata %struct.C** %this.addr.i, metadata !232, metadata !DIExpression()), !dbg !39
99  %this1.i = load %struct.C*, %struct.C** %this.addr.i, !dbg !37
100  ret void, !dbg !37
101}
102
103; Function Attrs: alwaysinline nounwind
104define void @_ZN1CD2Ev(%struct.C* %this) unnamed_addr #1 align 2 !dbg !16 {
105entry:
106  %this.addr = alloca %struct.C*, align 8
107  store %struct.C* %this, %struct.C** %this.addr, align 8
108  call void @llvm.dbg.declare(metadata %struct.C** %this.addr, metadata !32, metadata !DIExpression()), !dbg !40
109  %this1 = load %struct.C*, %struct.C** %this.addr
110  ret void, !dbg !41
111}
112
113; Function Attrs: nounwind readnone
114declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
115
116attributes #0 = { nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
117attributes #1 = { alwaysinline nounwind "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
118attributes #2 = { nounwind readnone }
119
120!llvm.dbg.cu = !{!0}
121!llvm.module.flags = !{!18, !19}
122!llvm.ident = !{!20}
123
124!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
125!1 = !DIFile(filename: "<stdin>", directory: "/tmp/dbginfo")
126!2 = !{}
127!3 = !{!4}
128!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", line: 1, size: 8, align: 8, file: !5, elements: !6, identifier: "_ZTS1C")
129!5 = !DIFile(filename: "PR20038.cpp", directory: "/tmp/dbginfo")
130!6 = !{!7}
131!7 = !DISubprogram(name: "~C", line: 2, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !5, scope: !4, type: !8)
132!8 = !DISubroutineType(types: !9)
133!9 = !{null, !10}
134!10 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
135!12 = distinct !DISubprogram(name: "fun4", linkageName: "_Z4fun4v", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 5, file: !5, scope: !13, type: !14, retainedNodes: !2)
136!13 = !DIFile(filename: "PR20038.cpp", directory: "/tmp/dbginfo")
137!14 = !DISubroutineType(types: !15)
138!15 = !{null}
139!16 = distinct !DISubprogram(name: "~C", linkageName: "_ZN1CD2Ev", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 6, file: !5, scope: !4, type: !8, declaration: !7, retainedNodes: !2)
140!17 = distinct !DISubprogram(name: "~C", linkageName: "_ZN1CD1Ev", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 6, file: !5, scope: !4, type: !8, declaration: !7, retainedNodes: !2)
141!18 = !{i32 2, !"Dwarf Version", i32 4}
142!19 = !{i32 2, !"Debug Info Version", i32 3}
143!20 = !{!"clang version 3.5.0 "}
144!21 = !DILocation(line: 6, scope: !17, inlinedAt: !22)
145!22 = !DILocation(line: 5, scope: !23)
146!23 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
147!24 = !DILocation(line: 5, scope: !12)
148!25 = !DILocation(line: 5, scope: !26)
149!26 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
150!27 = !DILocation(line: 5, scope: !28)
151!28 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
152!29 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !17, type: !30)
153!30 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !4)
154!31 = !DILocation(line: 0, scope: !17, inlinedAt: !22)
155!32 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !16, type: !30)
156!33 = !DILocation(line: 0, scope: !16, inlinedAt: !21)
157
158!129 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !17, type: !30)
159!132 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !16, type: !30)
160!232 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !16, type: !30)
161
162!34 = !DILocation(line: 5, scope: !35)
163!35 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !36)
164!36 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
165!37 = !DILocation(line: 6, scope: !17)
166!38 = !DILocation(line: 0, scope: !17)
167!39 = !DILocation(line: 0, scope: !16, inlinedAt: !37)
168!40 = !DILocation(line: 0, scope: !16)
169!41 = !DILocation(line: 6, scope: !16)
170