[PATCH] D100951: [llvm-dwarfdump] Fix split-dwarf bug in stats for inlined var loc cov

Djordje Todorovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 02:33:53 PDT 2021


djtodoro updated this revision to Diff 339532.
djtodoro added a comment.

- Reduce test
- Improve the comment


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100951/new/

https://reviews.llvm.org/D100951

Files:
  llvm/test/tools/llvm-dwarfdump/X86/Inputs/split-dwarf-test
  llvm/test/tools/llvm-dwarfdump/X86/Inputs/test1.dwo
  llvm/test/tools/llvm-dwarfdump/X86/Inputs/test2.dwo
  llvm/test/tools/llvm-dwarfdump/X86/inlined_variables_with_zero_cov.test
  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
@@ -720,11 +720,19 @@
   StringRef FormatName = Obj.getFileFormatName();
   GlobalStats GlobalStats;
   LocationStats LocStats;
-  InlinedVarsTyMap GlobalInlinedFnInfo;
-  InlinedFnInstacesTy InlinedFnsToBeProcessed;
   StringMap<PerFunctionStats> Statistics;
   for (const auto &CU : static_cast<DWARFContext *>(&DICtx)->compile_units()) {
     if (DWARFDie CUDie = CU->getNonSkeletonUnitDIE(false)) {
+      // These variables are being reset for each CU, since there could be
+      // a situation where we have two subprogram DIEs with the same offsets
+      // in two diferent CUs, and we can end up using wrong variables info
+      // when trying to resolve abstract_orign attribute.
+      // TODO: Handle LTO cases where the abstract origin of
+      // the function is in a different CU than the one it's
+      // referenced from or inlined into.
+      InlinedVarsTyMap GlobalInlinedFnInfo;
+      InlinedFnInstacesTy InlinedFnsToBeProcessed;
+
       collectStatsRecursive(CUDie, "/", "g", 0, 0, Statistics, GlobalStats,
                             LocStats, GlobalInlinedFnInfo,
                             InlinedFnsToBeProcessed);
Index: llvm/test/tools/llvm-dwarfdump/X86/inlined_variables_with_zero_cov.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-dwarfdump/X86/inlined_variables_with_zero_cov.test
@@ -0,0 +1,32 @@
+## This checks the number of inlined variables with 0% location
+## coverage in split dwarf cases.
+##  $ cat test1.cpp
+##  __attribute__((optnone)) static void x() {
+##  }
+##  __attribute__((always_inline)) static void y() {
+##    int var;
+##    x();
+##  }
+##  void f1() {
+##    y();
+##  }
+##
+##  $ cat test2.cpp
+##  __attribute__((optnone)) static void x() {
+##  }
+##  __attribute__((always_inline)) static void y() {
+##    int var;
+##    x();
+##  }
+##  void f1();
+##  int main() {
+##    f1();
+##    y();
+##  }
+##  $ clang++ -O1 -g -gsplit-dwarf test2.cpp test1.cpp -o split-dwarf-test
+##
+RUN: llvm-dwarfdump --statistics %S/Inputs/split-dwarf-test | FileCheck %s
+CHECK: "#variables processed by location statistics": 2
+CHECK: "#variables with 0% of parent scope covered by DW_AT_location": 2
+CHECK: "#local vars processed by location statistics": 2
+CHECK: "#local vars with 0% of parent scope covered by DW_AT_location": 2


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100951.339532.patch
Type: text/x-patch
Size: 2566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210422/f96cb5e5/attachment.bin>


More information about the llvm-commits mailing list