xref: /llvm-project/llvm/test/DebugInfo/Generic/PR20038.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1; For some reason, the output when targetting sparc is not quite as expected.
2; XFAIL: target=sparc{{.*}}
3
4; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -debug-info - | FileCheck %s --implicit-check-not=DW_TAG
5; RUN: %llc_dwarf --try-experimental-debuginfo-iterators -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -debug-info - | FileCheck %s --implicit-check-not=DW_TAG
6
7; IR generated from clang -O0 with:
8; struct C {
9;   ~C();
10; };
11; extern bool b;
12; void fun4() { b && (C(), 1); }
13; __attribute__((always_inline)) C::~C() { }
14
15; CHECK: DW_TAG_compile_unit
16
17; CHECK:   DW_TAG_structure_type
18; CHECK:     DW_AT_name ("C")
19; CHECK:     DW_TAG_subprogram
20; CHECK:       DW_AT_name ("~C")
21; CHECK:       DW_TAG_formal_parameter
22; CHECK:   DW_TAG_pointer_type
23
24; CHECK:   DW_TAG_subprogram
25; CHECK:     DW_AT_linkage_name ("_ZN1CD1Ev")
26; CHECK:     DW_TAG_formal_parameter
27; CHECK:       DW_AT_name ("this")
28; CHECK:   DW_TAG_pointer_type
29
30; CHECK:   DW_TAG_subprogram
31; CHECK:     DW_AT_name ("fun4")
32; CHECK:     DW_TAG_inlined_subroutine
33; CHECK:       DW_AT_abstract_origin {{.*}} "_ZN1CD1Ev"
34; CHECK:       DW_TAG_formal_parameter
35; CHECK:         DW_AT_abstract_origin {{.*}} "this"
36
37; CHECK:   DW_TAG_subprogram
38; CHECK:     DW_AT_abstract_origin {{.*}} "_ZN1CD1Ev"
39; CHECK:     DW_TAG_formal_parameter
40; CHECK:       DW_AT_abstract_origin {{.*}} "this"
41
42; CHECK:   DW_TAG_subprogram
43; CHECK:     DW_AT_linkage_name  ("_ZN1CD2Ev")
44; CHECK:     DW_AT_specification {{.*}} "~C"
45; CHECK:     DW_TAG_formal_parameter
46; CHECK:       DW_AT_name  ("this")
47
48%struct.C = type { i8 }
49
50@b = external global i8
51
52; Function Attrs: nounwind
53define void @_Z4fun4v() #0 !dbg !12 {
54entry:
55  %this.addr.i.i = alloca ptr, align 8, !dbg !21
56  %this.addr.i = alloca ptr, align 8, !dbg !22
57  %agg.tmp.ensured = alloca %struct.C, align 1
58  %cleanup.cond = alloca i1
59  %0 = load i8, ptr @b, align 1, !dbg !24
60  %tobool = trunc i8 %0 to i1, !dbg !24
61  store i1 false, ptr %cleanup.cond
62  br i1 %tobool, label %land.rhs, label %land.end, !dbg !24
63
64land.rhs:                                         ; preds = %entry
65  store i1 true, ptr %cleanup.cond, !dbg !25
66  br label %land.end
67
68land.end:                                         ; preds = %land.rhs, %entry
69  %1 = phi i1 [ false, %entry ], [ true, %land.rhs ]
70  %cleanup.is_active = load i1, ptr %cleanup.cond, !dbg !27
71  br i1 %cleanup.is_active, label %cleanup.action, label %cleanup.done, !dbg !27
72
73cleanup.action:                                   ; preds = %land.end
74  store ptr %agg.tmp.ensured, ptr %this.addr.i, align 8, !dbg !22
75  call void @llvm.dbg.declare(metadata ptr %this.addr.i, metadata !129, metadata !DIExpression()), !dbg !31
76  %this1.i = load ptr, ptr %this.addr.i, !dbg !22
77  store ptr %this1.i, ptr %this.addr.i.i, align 8, !dbg !21
78  call void @llvm.dbg.declare(metadata ptr %this.addr.i.i, metadata !132, metadata !DIExpression()), !dbg !33
79  %this1.i.i = load ptr, ptr %this.addr.i.i, !dbg !21
80  br label %cleanup.done, !dbg !22
81
82cleanup.done:                                     ; preds = %cleanup.action, %land.end
83  ret void, !dbg !34
84}
85
86; Function Attrs: alwaysinline nounwind
87define void @_ZN1CD1Ev(ptr %this) unnamed_addr #1 align 2 !dbg !17 {
88entry:
89  %this.addr.i = alloca ptr, align 8, !dbg !37
90  %this.addr = alloca ptr, align 8
91  store ptr %this, ptr %this.addr, align 8
92  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !29, metadata !DIExpression()), !dbg !38
93  %this1 = load ptr, ptr %this.addr
94  store ptr %this1, ptr %this.addr.i, align 8, !dbg !37
95  call void @llvm.dbg.declare(metadata ptr %this.addr.i, metadata !232, metadata !DIExpression()), !dbg !39
96  %this1.i = load ptr, ptr %this.addr.i, !dbg !37
97  ret void, !dbg !37
98}
99
100; Function Attrs: alwaysinline nounwind
101define void @_ZN1CD2Ev(ptr %this) unnamed_addr #1 align 2 !dbg !16 {
102entry:
103  %this.addr = alloca ptr, align 8
104  store ptr %this, ptr %this.addr, align 8
105  call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !32, metadata !DIExpression()), !dbg !40
106  %this1 = load ptr, ptr %this.addr
107  ret void, !dbg !41
108}
109
110; Function Attrs: nounwind readnone
111declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
112
113attributes #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" }
114attributes #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" }
115attributes #2 = { nounwind readnone }
116
117!llvm.dbg.cu = !{!0}
118!llvm.module.flags = !{!18, !19}
119!llvm.ident = !{!20}
120
121!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)
122!1 = !DIFile(filename: "<stdin>", directory: "/tmp/dbginfo")
123!2 = !{}
124!3 = !{!4}
125!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "C", line: 1, size: 8, align: 8, file: !5, elements: !6, identifier: "_ZTS1C")
126!5 = !DIFile(filename: "PR20038.cpp", directory: "/tmp/dbginfo")
127!6 = !{!7}
128!7 = !DISubprogram(name: "~C", line: 2, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !5, scope: !4, type: !8)
129!8 = !DISubroutineType(types: !9)
130!9 = !{null, !10}
131!10 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
132!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)
133!13 = !DIFile(filename: "PR20038.cpp", directory: "/tmp/dbginfo")
134!14 = !DISubroutineType(types: !15)
135!15 = !{null}
136!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)
137!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)
138!18 = !{i32 2, !"Dwarf Version", i32 4}
139!19 = !{i32 2, !"Debug Info Version", i32 3}
140!20 = !{!"clang version 3.5.0 "}
141!21 = !DILocation(line: 6, scope: !17, inlinedAt: !22)
142!22 = !DILocation(line: 5, scope: !23)
143!23 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
144!24 = !DILocation(line: 5, scope: !12)
145!25 = !DILocation(line: 5, scope: !26)
146!26 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
147!27 = !DILocation(line: 5, scope: !28)
148!28 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
149!29 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !17, type: !30)
150!30 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !4)
151!31 = !DILocation(line: 0, scope: !17, inlinedAt: !22)
152!32 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !16, type: !30)
153!33 = !DILocation(line: 0, scope: !16, inlinedAt: !21)
154
155!129 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !17, type: !30)
156!132 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !16, type: !30)
157!232 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !16, type: !30)
158
159!34 = !DILocation(line: 5, scope: !35)
160!35 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !36)
161!36 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !12)
162!37 = !DILocation(line: 6, scope: !17)
163!38 = !DILocation(line: 0, scope: !17)
164!39 = !DILocation(line: 0, scope: !16, inlinedAt: !37)
165!40 = !DILocation(line: 0, scope: !16)
166!41 = !DILocation(line: 6, scope: !16)
167