1 ; RUN: llc -O0 %s -o - -filetype=obj \
2 ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s
4 ; Test that abstract origins in multiple CUs are uniqued.
6 ; CHECK: "#functions": 4,
7 ; CHECK: "#inlined functions": 2,
8 ; CHECK: "#unique source variables": 4,
9 ; CHECK-NEXT: "#source variables": 6,
10 ; CHECK-NEXT: "#source variables with location": 6,
13 ;extern "C" int getchar();
14 ;template<typename T> T __attribute__((always_inline)) inlined() {
15 ; if (getchar()=='a') {
26 ; int b = inlined<int>();
33 ; int a = inlined<int>();
41 ; ModuleID = 'linked.ll'
42 source_filename = "llvm-link"
43 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
44 target triple = "x86_64-apple-macosx10.14.0"
46 ; Function Attrs: noinline optnone ssp uwtable
47 define i32 @_Z1av() #0 !dbg !10 {
49 %retval.i = alloca i32, align 4
50 %i.i = alloca i32, align 4
51 call void @llvm.dbg.declare(metadata ptr %i.i, metadata !14, metadata !DIExpression()), !dbg !21
52 %i2.i = alloca i32, align 4
53 call void @llvm.dbg.declare(metadata ptr %i2.i, metadata !23, metadata !DIExpression()), !dbg !25
54 %a = alloca i32, align 4
55 call void @llvm.dbg.declare(metadata ptr %a, metadata !26, metadata !DIExpression()), !dbg !27
56 %call.i = call i32 @getchar(), !dbg !28
57 %cmp.i = icmp eq i32 %call.i, 97, !dbg !28
58 br i1 %cmp.i, label %if.then.i, label %if.else.i, !dbg !29
60 if.then.i: ; preds = %entry
61 %call1.i = call i32 @getchar(), !dbg !21
62 store i32 %call1.i, ptr %i.i, align 4, !dbg !21
63 %0 = load i32, ptr %i.i, align 4, !dbg !30
64 store i32 %0, ptr %retval.i, align 4, !dbg !30
65 br label %_Z7inlinedIiET_v.exit, !dbg !30
67 if.else.i: ; preds = %entry
68 store i32 97, ptr %i2.i, align 4, !dbg !25
69 %1 = load i32, ptr %i2.i, align 4, !dbg !31
70 store i32 %1, ptr %retval.i, align 4, !dbg !31
71 br label %_Z7inlinedIiET_v.exit, !dbg !31
73 _Z7inlinedIiET_v.exit: ; preds = %if.else.i, %if.then.i
74 %2 = load i32, ptr %retval.i, align 4, !dbg !32
75 store i32 %2, ptr %a, align 4, !dbg !27
76 %3 = load i32, ptr %a, align 4, !dbg !33
77 %add = add nsw i32 %3, 1, !dbg !33
78 ret i32 %add, !dbg !33
81 ; Function Attrs: nounwind readnone speculatable
82 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
84 declare i32 @getchar()
86 ; Function Attrs: noinline norecurse optnone ssp uwtable
87 define i32 @main() #3 !dbg !34 {
89 %retval = alloca i32, align 4
90 store i32 0, ptr %retval, align 4
91 %call = call i32 @_Z1av(), !dbg !35
92 %call1 = call i32 @_Z1bv(), !dbg !35
93 %add = add nsw i32 %call, %call1, !dbg !35
94 ret i32 %add, !dbg !35
97 ; Function Attrs: noinline optnone ssp uwtable
98 define i32 @_Z1bv() #0 !dbg !36 {
100 %retval.i = alloca i32, align 4
101 %i.i = alloca i32, align 4
102 call void @llvm.dbg.declare(metadata ptr %i.i, metadata !37, metadata !DIExpression()), !dbg !41
103 %i2.i = alloca i32, align 4
104 call void @llvm.dbg.declare(metadata ptr %i2.i, metadata !43, metadata !DIExpression()), !dbg !45
105 %b = alloca i32, align 4
106 call void @llvm.dbg.declare(metadata ptr %b, metadata !46, metadata !DIExpression()), !dbg !47
107 %call.i = call i32 @getchar(), !dbg !48
108 %cmp.i = icmp eq i32 %call.i, 97, !dbg !48
109 br i1 %cmp.i, label %if.then.i, label %if.else.i, !dbg !49
111 if.then.i: ; preds = %entry
112 %call1.i = call i32 @getchar(), !dbg !41
113 store i32 %call1.i, ptr %i.i, align 4, !dbg !41
114 %0 = load i32, ptr %i.i, align 4, !dbg !50
115 store i32 %0, ptr %retval.i, align 4, !dbg !50
116 br label %_Z7inlinedIiET_v.exit, !dbg !50
118 if.else.i: ; preds = %entry
119 store i32 97, ptr %i2.i, align 4, !dbg !45
120 %1 = load i32, ptr %i2.i, align 4, !dbg !51
121 store i32 %1, ptr %retval.i, align 4, !dbg !51
122 br label %_Z7inlinedIiET_v.exit, !dbg !51
124 _Z7inlinedIiET_v.exit: ; preds = %if.else.i, %if.then.i
125 %2 = load i32, ptr %retval.i, align 4, !dbg !52
126 store i32 %2, ptr %b, align 4, !dbg !47
127 %3 = load i32, ptr %b, align 4, !dbg !53
128 %add = add nsw i32 %3, 1, !dbg !53
129 ret i32 %add, !dbg !53
132 attributes #0 = { noinline optnone ssp uwtable }
133 attributes #1 = { nounwind readnone speculatable }
134 attributes #3 = { noinline norecurse optnone ssp uwtable }
136 !llvm.dbg.cu = !{!0, !3}
137 !llvm.ident = !{!5, !5}
138 !llvm.module.flags = !{!6, !7, !8, !9}
140 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 340541) (llvm/trunk 340540)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
141 !1 = !DIFile(filename: "a.cpp", directory: "/tmp")
143 !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang version 8.0.0 (trunk 340541) (llvm/trunk 340540)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
144 !4 = !DIFile(filename: "b.cpp", directory: "/tmp")
145 !5 = !{!"clang version 8.0.0 (trunk 340541) (llvm/trunk 340540)"}
146 !6 = !{i32 2, !"Dwarf Version", i32 4}
147 !7 = !{i32 2, !"Debug Info Version", i32 3}
148 !8 = !{i32 1, !"wchar_size", i32 4}
149 !9 = !{i32 7, !"PIC Level", i32 2}
150 !10 = distinct !DISubprogram(name: "a", linkageName: "_Z1av", scope: !1, file: !1, line: 3, type: !11, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
151 !11 = !DISubroutineType(types: !12)
153 !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
154 !14 = !DILocalVariable(name: "i", scope: !15, file: !16, line: 4, type: !13)
155 !15 = distinct !DILexicalBlock(scope: !17, file: !16, line: 3)
156 !16 = !DIFile(filename: "./header.h", directory: "/tmp")
157 !17 = distinct !DILexicalBlock(scope: !18, file: !16, line: 3)
158 !18 = distinct !DISubprogram(name: "inlined<int>", linkageName: "_Z7inlinedIiET_v", scope: !16, file: !16, line: 2, type: !11, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, templateParams: !19, retainedNodes: !2)
160 !20 = !DITemplateTypeParameter(name: "T", type: !13)
161 !21 = !DILocation(line: 4, scope: !15, inlinedAt: !22)
162 !22 = distinct !DILocation(line: 4, scope: !10)
163 !23 = !DILocalVariable(name: "i", scope: !24, file: !16, line: 7, type: !13)
164 !24 = distinct !DILexicalBlock(scope: !17, file: !16, line: 6)
165 !25 = !DILocation(line: 7, scope: !24, inlinedAt: !22)
166 !26 = !DILocalVariable(name: "a", scope: !10, file: !1, line: 4, type: !13)
167 !27 = !DILocation(line: 4, scope: !10)
168 !28 = !DILocation(line: 3, scope: !17, inlinedAt: !22)
169 !29 = !DILocation(line: 3, scope: !18, inlinedAt: !22)
170 !30 = !DILocation(line: 5, scope: !15, inlinedAt: !22)
171 !31 = !DILocation(line: 8, scope: !24, inlinedAt: !22)
172 !32 = !DILocation(line: 10, scope: !18, inlinedAt: !22)
173 !33 = !DILocation(line: 5, scope: !10)
174 !34 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 12, type: !11, isLocal: false, isDefinition: true, scopeLine: 12, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
175 !35 = !DILocation(line: 13, scope: !34)
176 !36 = distinct !DISubprogram(name: "b", linkageName: "_Z1bv", scope: !4, file: !4, line: 2, type: !11, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !3, retainedNodes: !2)
177 !37 = !DILocalVariable(name: "i", scope: !38, file: !16, line: 4, type: !13)
178 !38 = distinct !DILexicalBlock(scope: !39, file: !16, line: 3)
179 !39 = distinct !DILexicalBlock(scope: !40, file: !16, line: 3)
180 !40 = distinct !DISubprogram(name: "inlined<int>", linkageName: "_Z7inlinedIiET_v", scope: !16, file: !16, line: 2, type: !11, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !3, templateParams: !19, retainedNodes: !2)
181 !41 = !DILocation(line: 4, scope: !38, inlinedAt: !42)
182 !42 = distinct !DILocation(line: 3, scope: !36)
183 !43 = !DILocalVariable(name: "i", scope: !44, file: !16, line: 7, type: !13)
184 !44 = distinct !DILexicalBlock(scope: !39, file: !16, line: 6)
185 !45 = !DILocation(line: 7, scope: !44, inlinedAt: !42)
186 !46 = !DILocalVariable(name: "b", scope: !36, file: !4, line: 3, type: !13)
187 !47 = !DILocation(line: 3, scope: !36)
188 !48 = !DILocation(line: 3, scope: !39, inlinedAt: !42)
189 !49 = !DILocation(line: 3, scope: !40, inlinedAt: !42)
190 !50 = !DILocation(line: 5, scope: !38, inlinedAt: !42)
191 !51 = !DILocation(line: 8, scope: !44, inlinedAt: !42)
192 !52 = !DILocation(line: 10, scope: !40, inlinedAt: !42)
193 !53 = !DILocation(line: 4, scope: !36)