[llvm] [BOLT][DWARF] Refactor address ranges processing (PR #71225)

via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 5 15:05:02 PST 2023


================
@@ -4251,92 +4251,88 @@ uint64_t BinaryFunction::translateInputToOutputAddress(uint64_t Address) const {
                   BB->getOutputAddressRange().second);
 }
 
-DebugAddressRangesVector BinaryFunction::translateInputToOutputRanges(
-    const DWARFAddressRangesVector &InputRanges) const {
-  DebugAddressRangesVector OutputRanges;
+DebugAddressRangesVector
+BinaryFunction::translateInputToOutputRange(DebugAddressRange InRange) const {
+  DebugAddressRangesVector OutRanges;
 
+  // The function was removed from the output. Return an empty range.
   if (isFolded())
-    return OutputRanges;
+    return OutRanges;
 
-  // If the function hasn't changed return the same ranges.
+  // If the function hasn't changed return the same range.
   if (!isEmitted()) {
-    OutputRanges.resize(InputRanges.size());
-    llvm::transform(InputRanges, OutputRanges.begin(),
-                    [](const DWARFAddressRange &Range) {
-                      return DebugAddressRange(Range.LowPC, Range.HighPC);
-                    });
-    return OutputRanges;
+    OutRanges.emplace_back(InRange);
+    return OutRanges;
+  }
+
+  if (!containsAddress(InRange.LowPC))
+    return OutRanges;
+
+  // Special case of an empty range [X, X). Some tools expect X to be updated.
+  if (InRange.LowPC == InRange.HighPC) {
----------------
maksfb wrote:

Will return an empty range. Same as before. For more context: this function is not supposed to handle special values. E.g. all DWARF-specific processing should happen at a higher level.

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


More information about the llvm-commits mailing list