llvm.org GIT mirror llvm / 14911bb
lvm-dwarfdump: Stop counting out-of-line subprogram in the "inlined functions" statistic. DW_TAG_subprogram DIEs should not be counted in the inlined function statistic. This also addresses the source variables count, as that uses the inlined function count in its calculations. Differential revision: https://reviews.llvm.org/D57849 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353491 91177308-0d34-0410-b5e6-96231b3b80d8 Caroline Tice 8 months ago
4 changed file(s) with 32 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llc -O0 %s -o - -filetype=obj \
11 ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s
2 ; CHECK: "version":1
2 ; CHECK: "version":2
33
44 ; int GlobalConst = 42;
55 ; int Global;
33 ; Test that abstract origins in multiple CUs are uniqued.
44
55 ; CHECK: "source functions":4,
6 ; CHECK-SAME: "inlined functions":5,
6 ; CHECK-SAME: "inlined functions":2,
77 ; CHECK-SAME: "unique source variables":4
88 ; CHECK-SAME: "source variables":6
99 ; CHECK-SAME: "variables with location":6
44 ; The results for both tests should be identical.
55
66 ; CHECK: "source functions":4,
7 ; CHECK-SAME: "inlined functions":5,
7 ; CHECK-SAME: "inlined functions":2,
88 ; CHECK-SAME: "unique source variables":4
99 ; CHECK-SAME: "source variables":6
1010 ; CHECK-SAME: "variables with location":6
2222 StringSet<> VarsInFunction;
2323 /// Compile units also cover a PC range, but have this flag set to false.
2424 bool IsFunction = false;
25 /// Verify function definition has PC addresses (for detecting when
26 /// a function has been inlined everywhere).
27 bool HasPCAddresses = false;
2528 };
2629
2730 /// Holds accumulated global statistics about DIEs.
135138 GlobalStats.ScopeBytesFromFirstDefinition += BytesInScope;
136139 assert(GlobalStats.ScopeBytesCovered <=
137140 GlobalStats.ScopeBytesFromFirstDefinition);
141 } else if (Die.getTag() == dwarf::DW_TAG_member) {
142 FnStats.ConstantMembers++;
138143 } else {
139 FnStats.ConstantMembers++;
144 FnStats.TotalVarWithLoc += (unsigned)HasLoc;
140145 }
141146 }
142147
163168 if (Die.find(dwarf::DW_AT_declaration))
164169 return;
165170
171 // PC Ranges.
172 auto RangesOrError = Die.getAddressRanges();
173 if (!RangesOrError) {
174 llvm::consumeError(RangesOrError.takeError());
175 return;
176 }
177
178 auto Ranges = RangesOrError.get();
179 uint64_t BytesInThisScope = 0;
180 for (auto Range : Ranges)
181 BytesInThisScope += Range.HighPC - Range.LowPC;
182 ScopeLowPC = getLowPC(Die);
183
166184 // Count the function.
167185 if (!IsBlock) {
168186 StringRef Name = Die.getName(DINameKind::LinkageName);
174192 return;
175193 // We've seen an (inlined) instance of this function.
176194 auto &FnStats = FnStatMap[Name];
177 FnStats.NumFnInlined++;
195 if (IsInlinedFunction)
196 FnStats.NumFnInlined++;
178197 FnStats.IsFunction = true;
179 }
180
181 // PC Ranges.
182 auto RangesOrError = Die.getAddressRanges();
183 if (!RangesOrError) {
184 llvm::consumeError(RangesOrError.takeError());
185 return;
186 }
187
188 auto Ranges = RangesOrError.get();
189 uint64_t BytesInThisScope = 0;
190 for (auto Range : Ranges)
191 BytesInThisScope += Range.HighPC - Range.LowPC;
192 ScopeLowPC = getLowPC(Die);
198 if (BytesInThisScope && !IsInlinedFunction)
199 FnStats.HasPCAddresses = true;
200 }
193201
194202 if (BytesInThisScope) {
195203 BytesInScope = BytesInThisScope;
257265 /// The version number should be increased every time the algorithm is changed
258266 /// (including bug fixes). New metrics may be added without increasing the
259267 /// version.
260 unsigned Version = 1;
268 unsigned Version = 2;
261269 unsigned VarTotal = 0;
262270 unsigned VarUnique = 0;
263271 unsigned VarWithLoc = 0;
266274 for (auto &Entry : Statistics) {
267275 PerFunctionStats &Stats = Entry.getValue();
268276 unsigned TotalVars = Stats.VarsInFunction.size() * Stats.NumFnInlined;
277 // Count variables in concrete out-of-line functions and in global scope.
278 if (Stats.HasPCAddresses || !Stats.IsFunction)
279 TotalVars += Stats.VarsInFunction.size();
269280 unsigned Constants = Stats.ConstantMembers;
270281 VarWithLoc += Stats.TotalVarWithLoc + Constants;
271 VarTotal += TotalVars + Constants;
282 VarTotal += TotalVars;
272283 VarUnique += Stats.VarsInFunction.size();
273284 LLVM_DEBUG(for (auto &V : Stats.VarsInFunction) llvm::dbgs()
274285 << Entry.getKey() << ": " << V.getKey() << "\n");