[PATCH] D72983: [llvm-dwarfdump][Statistics] Ignore DW_TAG_subroutine_type in statistics

Kristina Bessonova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 18 12:53:11 PST 2020


krisb created this revision.
krisb added reviewers: djtodoro, aprantl.
krisb added a project: debug-info.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
krisb added a parent revision: D72797: [llvm-dwarfdump][Statistics] Distinguish functions/variables with same name across different CUs.

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 a number of parameters w/o location and decrease 'availability' metric significantly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72983

Files:
  llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
  llvm/tools/llvm-dwarfdump/Statistics.cpp


Index: llvm/tools/llvm-dwarfdump/Statistics.cpp
===================================================================
--- llvm/tools/llvm-dwarfdump/Statistics.cpp
+++ llvm/tools/llvm-dwarfdump/Statistics.cpp
@@ -357,8 +357,12 @@
                                   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;
Index: llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/statistics.ll
+++ 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 @@
 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 @@
 !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 @@
 !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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72983.238962.patch
Type: text/x-patch
Size: 2962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200118/95e59c0c/attachment.bin>


More information about the llvm-commits mailing list