R600/SI: Fix bug where immediates were being used in DS addr operands
[oota-llvm.git] / lib / DebugInfo / DWARFDebugRangeList.cpp
index 10f51b4aa09ccff5288b54ccdb7d39b6c55e172d..07b23b32d1f33ef697abe5119a2d0de84fdb781a 100644 (file)
@@ -37,10 +37,7 @@ bool DWARFDebugRangeList::extract(DataExtractor data, uint32_t *offset_ptr) {
       clear();
       return false;
     }
-    // The end of any given range list is marked by an end of list entry,
-    // which consists of a 0 for the beginning address offset
-    // and a 0 for the ending address offset.
-    if (entry.StartAddress == 0 && entry.EndAddress == 0)
+    if (entry.isEndOfListEntry())
       break;
     Entries.push_back(entry);
   }
@@ -48,11 +45,25 @@ bool DWARFDebugRangeList::extract(DataExtractor data, uint32_t *offset_ptr) {
 }
 
 void DWARFDebugRangeList::dump(raw_ostream &OS) const {
-  for (int i = 0, n = Entries.size(); i != n; ++i) {
-    const char *format_str = (AddressSize == 4) ? "%08x %08x %08x\n"
-                                                : "%08x %016x %016x\n";
-    OS << format(format_str, Offset, Entries[i].StartAddress,
-                                     Entries[i].EndAddress);
+  for (const RangeListEntry &RLE : Entries) {
+    const char *format_str = (AddressSize == 4
+                              ? "%08x %08"  PRIx64 " %08"  PRIx64 "\n"
+                              : "%08x %016" PRIx64 " %016" PRIx64 "\n");
+    OS << format(format_str, Offset, RLE.StartAddress, RLE.EndAddress);
   }
   OS << format("%08x <End of list>\n", Offset);
 }
+
+DWARFAddressRangesVector
+DWARFDebugRangeList::getAbsoluteRanges(uint64_t BaseAddress) const {
+  DWARFAddressRangesVector Res;
+  for (const RangeListEntry &RLE : Entries) {
+    if (RLE.isBaseAddressSelectionEntry(AddressSize)) {
+      BaseAddress = RLE.EndAddress;
+    } else {
+      Res.push_back(std::make_pair(BaseAddress + RLE.StartAddress,
+                                   BaseAddress + RLE.EndAddress));
+    }
+  }
+  return Res;
+}