[llvm] [DwarfDump] Add new set of line-table-related statistics to llvm-dwarfdump (PR #93289)

Stephen Tozer via llvm-commits llvm-commits at lists.llvm.org
Fri May 24 06:12:03 PDT 2024


================
@@ -882,8 +900,58 @@ bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
         CrossCUReferencesToBeResolved.push_back(
             DIELocation(CUDie.getDwarfUnit(), CrossCUReferencingDIEOffset));
     }
+    if (const auto *LineTable = DICtx.getLineTableForUnit(CU.get())) {
+      auto LastFileIdxOpt = LineTable->getLastValidFileIndex();
+      // Each CU has its own file index; in order to track unique line entries
+      // across CUs, we therefore need to map each CU file index to a global
+      // file index, which we store here.
+      DenseMap<uint64_t, uint16_t> CUFileMapping;
+      if (LastFileIdxOpt) {
----------------
SLTozer wrote:

Good point - `LastFileIdxOpt` doesn't technically need to be valid for the rest of the logic, but a line table without files wouldn't have any sequences either. That being said this part isn't a loop so can't be early-exited; I can move this and the LineTable variable out of the `if` block and use them together as a precondition though.

https://github.com/llvm/llvm-project/pull/93289


More information about the llvm-commits mailing list