[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRangesVector.

Recommit of r303159 "[DWARF] - Use DWARFAddressRange struct instead of uint64_t pair for DWARFAddressRangesVector"
All places were shitched to use DWARFAddressRange now.

Suggested during review of D33184.

llvm-svn: 303163
This commit is contained in:
George Rimar 2017-05-16 12:30:59 +00:00
parent 3824cca7b3
commit 4671f2e08c
5 changed files with 24 additions and 20 deletions

View File

@ -22,8 +22,13 @@ namespace llvm {
class raw_ostream; class raw_ostream;
struct DWARFAddressRange {
uint64_t LowPC;
uint64_t HighPC;
};
/// DWARFAddressRangesVector - represents a set of absolute address ranges. /// DWARFAddressRangesVector - represents a set of absolute address ranges.
typedef std::vector<std::pair<uint64_t, uint64_t>> DWARFAddressRangesVector; typedef std::vector<DWARFAddressRange> DWARFAddressRangesVector;
class DWARFDebugRangeList { class DWARFDebugRangeList {
public: public:

View File

@ -54,9 +54,8 @@ void DWARFDebugAranges::generate(DWARFContext *CTX) {
if (ParsedCUOffsets.insert(CUOffset).second) { if (ParsedCUOffsets.insert(CUOffset).second) {
DWARFAddressRangesVector CURanges; DWARFAddressRangesVector CURanges;
CU->collectAddressRanges(CURanges); CU->collectAddressRanges(CURanges);
for (const auto &R : CURanges) { for (const auto &R : CURanges)
appendRange(CUOffset, R.first, R.second); appendRange(CUOffset, R.LowPC, R.HighPC);
}
} }
} }

View File

@ -69,8 +69,8 @@ DWARFDebugRangeList::getAbsoluteRanges(uint64_t BaseAddress) const {
if (RLE.isBaseAddressSelectionEntry(AddressSize)) { if (RLE.isBaseAddressSelectionEntry(AddressSize)) {
BaseAddress = RLE.EndAddress; BaseAddress = RLE.EndAddress;
} else { } else {
Res.push_back(std::make_pair(BaseAddress + RLE.StartAddress, Res.push_back(
BaseAddress + RLE.EndAddress)); {BaseAddress + RLE.StartAddress, BaseAddress + RLE.EndAddress});
} }
} }
return Res; return Res;

View File

@ -60,8 +60,8 @@ static void dumpRanges(raw_ostream &OS, const DWARFAddressRangesVector& Ranges,
OS << '\n'; OS << '\n';
OS.indent(Indent); OS.indent(Indent);
OS << format("[0x%0*" PRIx64 " - 0x%0*" PRIx64 ")", OS << format("[0x%0*" PRIx64 " - 0x%0*" PRIx64 ")",
AddressSize*2, Range.first, AddressSize*2, Range.LowPC,
AddressSize*2, Range.second); AddressSize*2, Range.HighPC);
} }
} }
@ -229,9 +229,9 @@ DWARFDie::getAddressRanges() const {
return DWARFAddressRangesVector(); return DWARFAddressRangesVector();
// Single range specified by low/high PC. // Single range specified by low/high PC.
uint64_t LowPC, HighPC; uint64_t LowPC, HighPC;
if (getLowAndHighPC(LowPC, HighPC)) { if (getLowAndHighPC(LowPC, HighPC))
return DWARFAddressRangesVector(1, std::make_pair(LowPC, HighPC)); return {{LowPC, HighPC}};
}
// Multiple ranges from .debug_ranges section. // Multiple ranges from .debug_ranges section.
auto RangesOffset = toSectionOffset(find(DW_AT_ranges)); auto RangesOffset = toSectionOffset(find(DW_AT_ranges));
if (RangesOffset) { if (RangesOffset) {
@ -257,7 +257,7 @@ DWARFDie::collectChildrenAddressRanges(DWARFAddressRangesVector& Ranges) const {
bool DWARFDie::addressRangeContainsAddress(const uint64_t Address) const { bool DWARFDie::addressRangeContainsAddress(const uint64_t Address) const {
for (const auto& R : getAddressRanges()) { for (const auto& R : getAddressRanges()) {
if (R.first <= Address && Address < R.second) if (R.LowPC <= Address && Address < R.HighPC)
return true; return true;
} }
return false; return false;

View File

@ -349,18 +349,18 @@ void DWARFUnit::updateAddressDieMap(DWARFDie Die) {
if (Die.isSubroutineDIE()) { if (Die.isSubroutineDIE()) {
for (const auto &R : Die.getAddressRanges()) { for (const auto &R : Die.getAddressRanges()) {
// Ignore 0-sized ranges. // Ignore 0-sized ranges.
if (R.first == R.second) if (R.LowPC == R.HighPC)
continue; continue;
auto B = AddrDieMap.upper_bound(R.first); auto B = AddrDieMap.upper_bound(R.LowPC);
if (B != AddrDieMap.begin() && R.first < (--B)->second.first) { if (B != AddrDieMap.begin() && R.LowPC < (--B)->second.first) {
// The range is a sub-range of existing ranges, we need to split the // The range is a sub-range of existing ranges, we need to split the
// existing range. // existing range.
if (R.second < B->second.first) if (R.HighPC < B->second.first)
AddrDieMap[R.second] = B->second; AddrDieMap[R.HighPC] = B->second;
if (R.first > B->first) if (R.LowPC > B->first)
AddrDieMap[B->first].first = R.first; AddrDieMap[B->first].first = R.LowPC;
} }
AddrDieMap[R.first] = std::make_pair(R.second, Die); AddrDieMap[R.LowPC] = std::make_pair(R.HighPC, Die);
} }
} }
// Parent DIEs are added to the AddrDieMap prior to the Children DIEs to // Parent DIEs are added to the AddrDieMap prior to the Children DIEs to