[llvm] [BOLT][DWARF] Refactor updateDWARFObjectAddressRanges (PR #96006)

Alexander Yermolovich via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 07:38:45 PDT 2024


================
@@ -1605,6 +1613,34 @@ void DWARFRewriter::finalizeCompileUnits(DIEBuilder &DIEBlder,
                                          DIEStreamer &Streamer,
                                          CUOffsetMap &CUMap,
                                          const std::list<DWARFUnit *> &CUs) {
+  for (DWARFUnit *CU : CUs) {
+    if (CU->getVersion() != 4)
+      continue;
+    if (std::optional<uint64_t> DWOId = CU->getDWOId()) {
+      auto RangesWriterandDIEIterator =
+          LegacyRangesWritersAndDIEsByCU.find(*DWOId);
+      assert(RangesWriterandDIEIterator !=
+                 LegacyRangesWritersAndDIEsByCU.end() &&
+             "RangesWriter does not exist for DWOId");
+      RangesWriterAndDIE &RangesWriterAndDIE =
+          RangesWriterandDIEIterator->second;
+      if (RangesWriterAndDIE.Die) {
+        DIEValue DvalGNUBase =
+            RangesWriterAndDIE.Die->findAttribute(dwarf::DW_AT_GNU_ranges_base);
+        assert(DvalGNUBase &&
+               "GNU_ranges_base attribute does not exist for DWOId");
+        DIEBlder.replaceValue(
+            RangesWriterAndDIE.Die, dwarf::DW_AT_GNU_ranges_base,
+            DvalGNUBase.getForm(),
+            DIEInteger(LegacyRangesSectionWriter->getRangesBufferSize()));
+      }
+      if (RangesWriterAndDIE.Writer) {
----------------
ayermolo wrote:

Won't this always be true?

https://github.com/llvm/llvm-project/pull/96006


More information about the llvm-commits mailing list