[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 10:31:52 PDT 2024
================
@@ -882,8 +902,58 @@ bool dwarfdump::collectStatsForObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
CrossCUReferencesToBeResolved.push_back(
DIELocation(CUDie.getDwarfUnit(), CrossCUReferencingDIEOffset));
}
+ const auto *LineTable = DICtx.getLineTableForUnit(CU.get());
+ std::optional<uint64_t> LastFileIdxOpt;
+ if (LineTable)
+ LastFileIdxOpt = LineTable->getLastValidFileIndex();
+ if (LastFileIdxOpt) {
+ // 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;
+ std::string File;
+ for (uint64_t FileIdx = 0; FileIdx <= *LastFileIdxOpt; ++FileIdx) {
----------------
SLTozer wrote:
They are - but the method `getFileNameByIndex` will return `std::nullopt` if you fetch index 0 for DWARFv4 and earlier, and we have the correct final index for the for-loop from `getLastValidFileIndex`, so in this case this loop still does the right thing.
https://github.com/llvm/llvm-project/pull/93289
More information about the llvm-commits
mailing list