[llvm] [BOLT][DWARF] Refactor updateDWARFObjectAddressRanges (PR #96006)
Alexander Yermolovich via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 10:32:37 PDT 2024
================
@@ -2278,42 +2310,34 @@ void DWARFRewriter::convertToRangesPatchDebugInfo(
Die.getTag() == dwarf::DW_TAG_skeleton_unit;
if (!IsUnitDie)
DIEBldr.deleteValue(&Die, LowPCAttrInfo.getAttribute());
- // In DWARF4 for DW_AT_low_pc in binary DW_FORM_addr is used. In the DWO
- // section DW_FORM_GNU_addr_index is used. So for if we are converting
- // DW_AT_low_pc/DW_AT_high_pc and see DW_FORM_GNU_addr_index. We are
- // converting in DWO section, and DW_AT_ranges [DW_FORM_sec_offset] is
- // relative to DW_AT_GNU_ranges_base.
- if (LowForm == dwarf::DW_FORM_GNU_addr_index) {
- // Ranges are relative to DW_AT_GNU_ranges_base.
- uint64_t CurRangeBase = 0;
- if (std::optional<uint64_t> DWOId = Unit.getDWOId()) {
- CurRangeBase = getDwoRangesBase(*DWOId);
- }
- BaseOffset = CurRangeBase;
- } else {
- // In DWARF 5 we can have DW_AT_low_pc either as DW_FORM_addr, or
- // DW_FORM_addrx. Former is when DW_AT_rnglists_base is present. Latter is
- // when it's absent.
- if (IsUnitDie) {
- if (LowForm == dwarf::DW_FORM_addrx) {
- const uint32_t Index = AddrWriter->getIndexFromAddress(0, Unit);
- DIEBldr.replaceValue(&Die, LowPCAttrInfo.getAttribute(),
- LowPCAttrInfo.getForm(), DIEInteger(Index));
- } else {
- DIEBldr.replaceValue(&Die, LowPCAttrInfo.getAttribute(),
- LowPCAttrInfo.getForm(), DIEInteger(0));
- }
+
+ // In DWARF 5 we can have DW_AT_low_pc either as DW_FORM_addr, or
+ // DW_FORM_addrx. Former is when DW_AT_rnglists_base is present. Latter is
+ // when it's absent.
+ if (IsUnitDie) {
+ if (LowForm == dwarf::DW_FORM_addrx) {
+ const uint32_t Index = AddrWriter->getIndexFromAddress(0, Unit);
+ DIEBldr.replaceValue(&Die, LowPCAttrInfo.getAttribute(),
+ LowPCAttrInfo.getForm(), DIEInteger(Index));
+ } else {
+ DIEBldr.replaceValue(&Die, LowPCAttrInfo.getAttribute(),
+ LowPCAttrInfo.getForm(), DIEInteger(0));
}
- // Original CU didn't have DW_AT_*_base. We converted it's children (or
- // dwo), so need to insert it into CU.
- if (RangesBase)
+ }
+ // Original CU didn't have DW_AT_*_base. We converted it's children (or
+ // dwo), so need to insert it into CU.
+ if (RangesBase) {
+ if (Unit.getVersion() >= 5) {
DIEBldr.addValue(&Die, RangeBaseAttribute, dwarf::DW_FORM_sec_offset,
DIEInteger(*RangesBase));
+ } else {
+ DIEBldr.addValue(&Die, RangeBaseAttribute, dwarf::DW_FORM_sec_offset,
+ DIEInteger(INT_MAX));
+ UpdatedDIEsByDWO[*Unit.getDWOId()] = &Die;
+ }
}
- uint64_t RangeAttrVal = RangesSectionOffset - BaseOffset;
- if (Unit.getVersion() >= 5)
- RangeAttrVal = RangesSectionOffset;
+ uint64_t RangeAttrVal = RangesSectionOffset;
----------------
ayermolo wrote:
can just use RangesSectionOffset directly
https://github.com/llvm/llvm-project/pull/96006
More information about the llvm-commits
mailing list