[llvm] [RFC][BOLT] Add a new parallel DWARF processing(2/2) (PR #197859)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 09:53:35 PDT 2026
================
@@ -429,6 +455,48 @@ static bool getLowAndHighPC(const DIE &Die, const DWARFUnit &DU,
return false;
}
+static void fixupDWARFRanges(DIEBuilder &DIEBlder, DWARFUnit &Unit,
+ uint64_t Offset) {
+ if (Offset == 0)
+ return;
+
+ const uint16_t Version = Unit.getVersion();
+ if (Version >= 5) {
+ DIE *CUDie = DIEBlder.getUnitDIEbyUnit(Unit);
+ DIEValue RngBaseVal = CUDie->findAttribute(dwarf::DW_AT_rnglists_base);
+ if (RngBaseVal) {
+ uint64_t OldVal = RngBaseVal.getDIEInteger().getValue();
+ DIEBlder.replaceValue(CUDie, dwarf::DW_AT_rnglists_base,
+ RngBaseVal.getForm(), DIEInteger(OldVal + Offset));
+ }
+ }
+
+ const auto &DIs = DIEBlder.getDIEsByUnit(Unit);
+ for (const auto &DI : DIs) {
+ DIE *Die = DI->Die;
+ DIEValue RangesVal = Die->findAttribute(dwarf::DW_AT_ranges);
+ if (RangesVal &&
+ (Version < 5 || RangesVal.getForm() == dwarf::DW_FORM_sec_offset)) {
+ uint64_t OldVal = RangesVal.getDIEInteger().getValue();
+ // Empty ranges are stored at offset 0 in both local and global
+ // buffers, so must not be shifted during merge.
+ if (OldVal != DebugRangesSectionWriter::getEmptyRangesOffset())
+ DIEBlder.replaceValue(Die, dwarf::DW_AT_ranges, RangesVal.getForm(),
+ DIEInteger(OldVal + Offset));
+ }
+
+ if (Version < 5) {
----------------
ayermolo wrote:
DW_AT_GNU_ranges_base is DWARF4-split-only, and it points into the per-DWO ranges block — not the per-bucket LocalWriter.LegacyRangesWriter that fixupDWARFRanges() is rebasing. So OldVal + Offset here adds the wrong base. finalizeCompileUnits() then unconditionally overwrites it with the correct per-DWO global offset via setDie() + replaceValue(), and every GNU_ranges_base-bearing CU gets setDie() recorded (updateDWARFObjectAddressRanges and convertToRangesPatchDebugInfo), so the overwrite always happens.
https://github.com/llvm/llvm-project/pull/197859
More information about the llvm-commits
mailing list