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 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 Statistics; for (const auto &CU : static_cast(&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);