Skip to content

Commit 4624087

Browse files
authored
[llvm-dwarfdump] Print number of out-of-line functions described by DWARF (#127233)
Some of the functions in `#functions` may have several inlined instances, but also an out-of-line definition. Therefore, for complex enough DWARF input, `#functions` - `#inlined functions` would not give us the number of out-of-line function definitions. `llvm-dwarfdump`, however, already keeps track of those; print it as part of the statistics, as this number is useful in certain scenarios.
1 parent 26a8399 commit 4624087

7 files changed

+9
-0
lines changed

llvm/test/tools/llvm-dwarfdump/X86/statistics-dwo.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ RUN: llvm-dwarfdump --statistics statistics-fib.split-dwarf.o | FileCheck %s
7272
CHECK: "version": 9,
7373
CHECK: "#functions": 3,
7474
CHECK: "#functions with location": 3,
75+
CHECK: "#out-of-line functions": 3,
7576
CHECK: "#inlined functions": 7,
7677
CHECK: "#inlined functions with abstract origins": 7,
7778
CHECK: "#unique source variables": 9,

llvm/test/tools/llvm-dwarfdump/X86/statistics-v3.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ RUN: llvm-dwarfdump --statistics %t-statistics-fib.o | FileCheck %s
6767
CHECK: "version": 9,
6868
CHECK: "#functions": 3,
6969
CHECK: "#functions with location": 3,
70+
CHECK: "#out-of-line functions": 3,
7071
CHECK: "#inlined functions": 8,
7172
CHECK: "#inlined functions with abstract origins": 8,
7273
CHECK: "#unique source variables": 9,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
; Test that abstract origins in multiple CUs are uniqued.
55

66
; CHECK: "#functions": 4,
7+
; CHECK: "#out-of-line functions": 3,
78
; CHECK: "#inlined functions": 2,
89
; CHECK: "#unique source variables": 4,
910
; CHECK-NEXT: "#source variables": 6,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
; The results for both tests should be identical.
66

77
; CHECK: "#functions": 4,
8+
; CHECK: "#out-of-line functions": 3,
89
; CHECK: "#inlined functions": 2,
910
; CHECK: "#unique source variables": 4,
1011
; CHECK-NEXT: "#source variables": 6,

llvm/test/tools/llvm-dwarfdump/X86/stats-mulitple-cu-out-of-line.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
; CHECK: "#functions": 3,
2222
; CHECK-NEXT: "#functions with location": 3,
23+
; CHECK-NEXT: "#out-of-line functions": 4,
2324
; CHECK-NEXT: "#inlined functions": 0,
2425
; CHECK-NEXT: "#inlined functions with abstract origins": 0,
2526
; CHECK-NEXT: "#unique source variables": 1,

llvm/test/tools/llvm-dwarfdump/X86/stats-multiple-cu-same-name.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
; Test that statistics distinguish functions with the same name.
55

66
; CHECK: "#functions": 4,
7+
; CHECK: "#out-of-line functions": 4,
78
; CHECK: "#unique source variables": 2,
89
; CHECK-NEXT: "#source variables": 2,
910

llvm/tools/llvm-dwarfdump/Statistics.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,7 @@ bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
971971
SaturatingUINT64 VarParamUnique = 0;
972972
SaturatingUINT64 VarParamWithLoc = 0;
973973
SaturatingUINT64 NumFunctions = 0;
974+
SaturatingUINT64 NumOutOfLineFunctions = 0;
974975
SaturatingUINT64 NumInlinedFunctions = 0;
975976
SaturatingUINT64 NumFuncsWithSrcLoc = 0;
976977
SaturatingUINT64 NumAbstractOrigins = 0;
@@ -999,6 +1000,7 @@ bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
9991000
<< Entry.getKey() << ": " << V.getKey() << "\n");
10001001
NumFunctions += Stats.IsFunction;
10011002
NumFuncsWithSrcLoc += Stats.HasSourceLocation;
1003+
NumOutOfLineFunctions += Stats.IsFunction * Stats.NumFnOutOfLine;
10021004
NumInlinedFunctions += Stats.IsFunction * Stats.NumFnInlined;
10031005
NumAbstractOrigins += Stats.IsFunction * Stats.NumAbstractOrigins;
10041006
ParamTotal += Stats.NumParams;
@@ -1024,6 +1026,7 @@ bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
10241026

10251027
printDatum(J, "#functions", NumFunctions.Value);
10261028
printDatum(J, "#functions with location", NumFuncsWithSrcLoc.Value);
1029+
printDatum(J, "#out-of-line functions", NumOutOfLineFunctions.Value);
10271030
printDatum(J, "#inlined functions", NumInlinedFunctions.Value);
10281031
printDatum(J, "#inlined functions with abstract origins",
10291032
NumAbstractOrigins.Value);

0 commit comments

Comments
 (0)