[PATCH] D73003: [llvm-dwarfdump][Statistics] Distinguish parameters with same name or w/o a name

Kristina Bessonova via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 19 08:13:26 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.

  A few DW_TAG_formal_parameter's of the same function may have the same
  name (e.g. variadic (template) functions) or don't have a name at all
  (if the parameter isn't used inside the function body), but we still
  need to be able to distinguish between them to get the correct number of 'total vars'
  and 'availability' metric.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73003

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
@@ -441,11 +441,14 @@
 
   // Traverse children.
   unsigned LexicalBlockIndex = 0;
+  unsigned FormalParameterIndex = 0;
   DWARFDie Child = Die.getFirstChild();
   while (Child) {
     std::string ChildVarPrefix = VarPrefix;
     if (Child.getTag() == dwarf::DW_TAG_lexical_block)
       ChildVarPrefix += toHex(LexicalBlockIndex++) + '.';
+    if (Child.getTag() == dwarf::DW_TAG_formal_parameter)
+      ChildVarPrefix += 'p' + toHex(FormalParameterIndex++) + '.';
 
     collectStatsRecursive(Child, FnPrefix, ChildVarPrefix, BytesInScope,
                           InlineDepth, FnStatMap, GlobalStats, LocStats);
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
@@ -15,6 +15,8 @@
 ;   int squared = square(i);
 ;   return squared*i;
 ; }
+;
+; int boo(int, int) {}
 
 ; Following variables/arguments/members should be counted:
 ;     - GlobalConst,
@@ -22,12 +24,13 @@
 ;     - s, s.constant ('fn' and its arguments should be skipped),
 ;     - square::i,
 ;     - cube::i, cube::squared
+;     - boo::1, boo::2
 
-; CHECK: "unique source variables":7
+; CHECK: "unique source variables":9
 ; +1 extra inline i.
-; CHECK: "source variables":8
+; CHECK: "source variables":10
 ; -1 square::i
-; CHECK: "variables with location":7
+; CHECK: "variables with location":9
 ; CHECK: "scope bytes total":[[BYTES:[0-9]+]]
 ; Because of the dbg.value in the middle of the function, the pc range coverage
 ; must be below 100%.
@@ -90,6 +93,18 @@
   ret i32 %mul, !dbg !44
 }
 
+; Function Attrs: noinline optnone uwtable
+define dso_local i32 @_Z3booii(i32 %0, i32 %1) !dbg !48 {
+entry:
+  %.addr = alloca i32, align 4
+  %.addr1 = alloca i32, align 4
+  store i32 %0, i32* %.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %.addr, metadata !51, metadata !DIExpression()), !dbg !52
+  store i32 %1, i32* %.addr1, align 4
+  call void @llvm.dbg.declare(metadata i32* %.addr1, metadata !53, metadata !DIExpression()), !dbg !54
+  ret i32 0, !dbg !54
+}
+
 attributes #0 = { alwaysinline nounwind ssp uwtable }
 attributes #1 = { nounwind readnone speculatable }
 attributes #2 = { noinline nounwind optnone ssp uwtable }
@@ -146,3 +161,10 @@
 !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)
+!48 = distinct !DISubprogram(name: "boo", linkageName: "_Z3booii", scope: !3, file: !3, line: 10, type: !49, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!49 = !DISubroutineType(types: !50)
+!50 = !{!8, !8, !8}
+!51 = !DILocalVariable(arg: 1, scope: !48, file: !3, line: 10, type: !8)
+!52 = !DILocation(line: 10, column: 12, scope: !48)
+!53 = !DILocalVariable(arg: 2, scope: !48, file: !3, line: 10, type: !8)
+!54 = !DILocation(line: 10, column: 17, scope: !48)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73003.238995.patch
Type: text/x-patch
Size: 3276 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200119/343df4b3/attachment.bin>


More information about the llvm-commits mailing list