[llvm] [DebugInfo] Add fast path for parsing DW_TAG_compile_unit abbrevs (PR #108757)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 10:17:02 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) {
----------------
dwblaikie wrote:
1) minor, we don't usually do these "constant on the LHS" style comparison in LLVM, I think?
2) The abbreviation numbers in the abbrev table are arbitrary/not ordered - so we probably shouldn't be needing/trying to check for the value is 1.
Could this either generalize this to check the first abbrev in the table, regardless of numbering - or change abbrev parsing to be lazy in general? (like parse as much of the table as is needed to find the number - oh, I guess we do have some optimizations that only fire if the abbrev numbering is strictly increasing (doesn't have to start at 1, doesn't have to increase by 1 each time - but so long as it's always increasing we can still binary search))
https://github.com/llvm/llvm-project/pull/108757
More information about the llvm-commits
mailing list