[llvm] e76106e - [llvm-dwarfdump][Statistics] Ignore DW_TAG_subroutine_type in statistics
Kristina Bessonova via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 28 09:51:13 PST 2020
Author: Kristina Bessonova
Date: 2020-01-28T19:50:46+02:00
New Revision: e76106e01c4b79894ac9c28e48e786121e1cdb6c
URL: https://github.com/llvm/llvm-project/commit/e76106e01c4b79894ac9c28e48e786121e1cdb6c
DIFF: https://github.com/llvm/llvm-project/commit/e76106e01c4b79894ac9c28e48e786121e1cdb6c.diff
LOG: [llvm-dwarfdump][Statistics] Ignore DW_TAG_subroutine_type in statistics
DW_TAG_subroutine_type is not really useful for statistics purposes, as it never
has location information. But it may contain DW_TAG_formal_parameter
children that generate number of parameters w/o location and decrease
'availability' metric significantly.
Reviewed by: djtodoro
Differential Revision: https://reviews.llvm.org/D72983
Added:
Modified:
llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
llvm/tools/llvm-dwarfdump/Statistics.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/statistics.ll b/llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
index f8d9326ff8e3..4e2e11109de6 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
+++ b/llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
@@ -7,6 +7,7 @@
;
; struct S {
; static const int constant = 24;
+; int (*fn)(int);
; } s;
;
; int __attribute__((always_inline)) square(int i) { return i * i; }
@@ -15,7 +16,13 @@
; return squared*i;
; }
-; GlobalConst,Global,s,s.constant,square::i,cube::i,cube::squared
+; Following variables/arguments/members should be counted:
+; - GlobalConst,
+; - Global,
+; - s, s.constant ('fn' and its arguments should be skipped),
+; - square::i,
+; - cube::i, cube::squared
+
; CHECK: "unique source variables":7
; +1 extra inline i.
; CHECK: "source variables":8
@@ -36,7 +43,7 @@ source_filename = "/tmp/quality.cpp"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
-%struct.S = type { i8 }
+%struct.S = type { i8 (i32)* }
@GlobalConst = global i32 42, align 4, !dbg !0
@Global = global i32 0, align 4, !dbg !6
@@ -103,7 +110,7 @@ attributes #2 = { noinline nounwind optnone ssp uwtable }
!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
!10 = distinct !DIGlobalVariable(name: "s", scope: !2, file: !3, line: 6, type: !11, isLocal: false, isDefinition: true)
!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !3, line: 4, size: 8, elements: !12, identifier: "_ZTS1S")
-!12 = !{!13}
+!12 = !{!13, !45}
!13 = !DIDerivedType(tag: DW_TAG_member, name: "constant", scope: !11, file: !3, line: 5, baseType: !14, flags: DIFlagStaticMember, extraData: i32 24)
!14 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
!15 = !{i32 2, !"Dwarf Version", i32 4}
@@ -136,3 +143,6 @@ attributes #2 = { noinline nounwind optnone ssp uwtable }
!42 = !DILocation(line: 11, column: 18, scope: !30)
!43 = !DILocation(line: 11, column: 17, scope: !30)
!44 = !DILocation(line: 11, column: 3, scope: !30)
+!45 = !DIDerivedType(tag: DW_TAG_member, name: "fn", scope: !11, file: !3, line: 5, baseType: !46, size: 64)
+!46 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !47, size: 64)
+!47 = !DISubroutineType(types: !22)
diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp
index c77e9e40193a..642484f82308 100644
--- a/llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -353,8 +353,12 @@ static void collectStatsRecursive(DWARFDie Die, std::string FnPrefix,
StringMap<PerFunctionStats> &FnStatMap,
GlobalStats &GlobalStats,
LocationStats &LocStats) {
- // Handle any kind of lexical scope.
const dwarf::Tag Tag = Die.getTag();
+ // Skip function types.
+ if (Tag == dwarf::DW_TAG_subroutine_type)
+ return;
+
+ // Handle any kind of lexical scope.
const bool IsFunction = Tag == dwarf::DW_TAG_subprogram;
const bool IsBlock = Tag == dwarf::DW_TAG_lexical_block;
const bool IsInlinedFunction = Tag == dwarf::DW_TAG_inlined_subroutine;
More information about the llvm-commits
mailing list