[llvm] [DebugInfo] Add fast path for parsing DW_TAG_compile_unit abbrevs (PR #108757)
Daniel Bertalan via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 17 11:47:15 PDT 2024
================
@@ -34,36 +34,49 @@ bool DWARFDebugInfoEntry::extractFast(const DWARFUnit &U, uint64_t *OffsetPtr,
return false;
}
assert(DebugInfoData.isValidOffset(UEndOffset - 1));
+ AbbrevDecl = nullptr;
+
uint64_t AbbrCode = DebugInfoData.getULEB128(OffsetPtr);
if (0 == AbbrCode) {
// NULL debug tag entry.
- AbbrevDecl = nullptr;
return true;
}
- const auto *AbbrevSet = U.getAbbreviations();
- if (!AbbrevSet) {
- U.getContext().getWarningHandler()(
- createStringError(errc::invalid_argument,
- "DWARF unit at offset 0x%8.8" PRIx64 " "
- "contains invalid abbreviation set offset 0x%" PRIx64,
- U.getOffset(), U.getAbbreviationsOffset()));
- // Restore the original offset.
- *OffsetPtr = Offset;
- return false;
+
+ // Fast path: parsing the entire abbreviation table is wasteful if we only
+ // need the unit DIE (typically AbbrCode == 1).
+ if (1 == AbbrCode) {
----------------
BertalanD wrote:
(will reflect on the other bits later):
> Why is ld64 reading the CUs anyway?
For emitting `N_OSO` stabs; which indicate the source file names of symbols. We need to read `DW_AT_source_dir` for this, see `ObjFile::source_file` in LLD.
https://github.com/llvm/llvm-project/pull/108757
More information about the llvm-commits
mailing list