[llvm] [BOLT][DWARF][NFC] Refactor updateUnitDebugInfo (PR #100811)

Alexander Yermolovich via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 26 14:14:01 PDT 2024


================
@@ -912,123 +944,163 @@ void DWARFRewriter::updateUnitDebugInfo(
       }
 
       if (FunctionRanges.size() == 1 && !opts::AlwaysConvertToRanges) {
-        updateLowPCHighPC(Die, LowPCVal, HighPCVal, FunctionRanges.back().LowPC,
+        updateLowPCHighPC(&Die, LowPCVal, HighPCVal,
+                          FunctionRanges.back().LowPC,
                           FunctionRanges.back().HighPC);
-        break;
+        return;
       }
 
       updateDWARFObjectAddressRanges(
-          Unit, DIEBldr, *Die, RangesSectionWriter.addRanges(FunctionRanges));
+          Unit, DIEBldr, Die, RangesSectionWriter.addRanges(FunctionRanges));
+}
 
-      break;
+void DWARFRewriter::handleLexicalBlock(
+    DIE &Die, DWARFUnit &Unit, DIEBuilder &DIEBldr,
+    DebugRangesSectionWriter &RangesSectionWriter,
+    DebugAddrWriter &AddressWriter,
+    std::map<DebugAddressRangesVector, uint64_t> &CachedRanges) {
+  auto updateLowPCHighPC = [&](DIE *Die, const DIEValue &LowPCVal,
----------------
ayermolo wrote:

Don't duplicate code.

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


More information about the llvm-commits mailing list