[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
Wed Apr 21 06:36:14 PDT 2021
djtodoro created this revision.
djtodoro added reviewers: dblaikie, aprantl.
djtodoro added a project: debug-info.
Herald added a reviewer: jhenderson.
Herald added a subscriber: cmtice.
djtodoro requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Initial (D96045 <https://reviews.llvm.org/D96045>) patch didn't handle split dwarf cases, so this fixes that bug.
In addition, before applying this patch, we had a slowdown that happened after the D96045 <https://reviews.llvm.org/D96045>. With this patch, the slowdown will be fixed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100951
Files:
llvm/test/tools/llvm-dwarfdump/X86/Inputs/main.dwo
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,17 @@
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 two variables are used for tracking of location coverage
+ // for variables from inlined functions.
+ // 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,39 @@
+## 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 f2() {
+## y();
+## }
+##
+## $ cat main.cpp
+## void f1();
+## void f2();
+## int main() {
+## f1();
+## f2();
+## }
+##
+## $ clang++ -O1 -g -gsplit-dwarf main.cpp 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.339213.patch
Type: text/x-patch
Size: 2488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210421/bf5293c9/attachment.bin>
More information about the llvm-commits
mailing list