[llvm] [RFC][BOLT] Add a new parallel DWARF processing(2/2) (PR #197859)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 01:09: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) {
----------------
Thrrreeee wrote:
This is not duplicate logic. `fixupDWARFRanges() `adjusts DW_AT_ranges / DW_AT_GNU_ranges_base values by a merge offset when per-bucket local ranges buffers are appended to the global buffer. `finalizeCompileUnits() `performs the deferred final patch for split DWARF: the real global .debug_ranges base is only known after the per-DWO ranges buffer is appended.(earlier code may only record the CU DIE in `updateDWARFObjectAddressRanges()` / `convertToRangesPatchDebugInfo()` )
https://github.com/llvm/llvm-project/pull/197859
More information about the llvm-commits
mailing list