Debian Codegraph @

llvm/test/tools/llvm-dwarfdump/X86/stats-inlining-multi-cu.ll

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