================ @@ -254,12 +254,32 @@ Function *IndirectCallEdge::GetCallee(ModuleList &images, /// @} +AddressRange CollapseRanges(llvm::ArrayRef<AddressRange> ranges) { + if (ranges.empty()) + return AddressRange(); + if (ranges.size() == 1) + return ranges[0]; + + Address lowest_addr = ranges[0].GetBaseAddress(); + addr_t highest_addr = lowest_addr.GetFileAddress() + ranges[0].GetByteSize(); + for (const AddressRange &range : ranges.drop_front()) { + Address range_begin = range.GetBaseAddress(); + addr_t range_end = range_begin.GetFileAddress() + range.GetByteSize(); + if (range_begin.GetFileAddress() < lowest_addr.GetFileAddress()) + lowest_addr = range_begin; + if (range_end > highest_addr) + highest_addr = range_end; + } + return AddressRange(lowest_addr, highest_addr - lowest_addr.GetFileAddress()); ---------------- labath wrote:
The problem is that the range may need extending at both ends (there's no guarantee the lowest address will be the first one). Extending it an the lower end is tricky as you need to both change the base address and increase the range size. Storing it decomposed and only constructing the range object at the end is simpler. https://github.com/llvm/llvm-project/pull/115730 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits