llvm-symbolizer: Fix bug related to TUs interfering with symbolizing

With the merge of TUs and CUs into a single container, some code that
relied on the CU range having an ordered range of contiguous addresses
(for locating a CU at a given offset) broke. But the units from
debug_info (currently only CUs, but CUs and TUs in DWARFv5) are in a
contiguous sub-range of that container - searching only through that
subrange is still valid & so do that.

llvm-svn: 341889
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 1b58ef7..b2bc2c8 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -113,12 +113,13 @@
 }
 
 DWARFUnit *DWARFUnitVector::getUnitForOffset(uint32_t Offset) const {
-  auto *CU = std::upper_bound(
-    this->begin(), this->end(), Offset,
-    [](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
-    return LHS < RHS->getNextUnitOffset();
-  });
-  if (CU != this->end() && (*CU)->getOffset() <= Offset)
+  auto end = begin() + getNumInfoUnits();
+  auto *CU =
+      std::upper_bound(begin(), end, Offset,
+                       [](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
+                         return LHS < RHS->getNextUnitOffset();
+                       });
+  if (CU != end && (*CU)->getOffset() <= Offset)
     return CU->get();
   return nullptr;
 }
@@ -130,13 +131,14 @@
     return nullptr;
 
   auto Offset = CUOff->Offset;
+  auto end = begin() + getNumInfoUnits();
 
-  auto *CU = std::upper_bound(
-    this->begin(), this->end(), CUOff->Offset,
-    [](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
-    return LHS < RHS->getNextUnitOffset();
-  });
-  if (CU != this->end() && (*CU)->getOffset() <= Offset)
+  auto *CU =
+      std::upper_bound(begin(), end, CUOff->Offset,
+                       [](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
+                         return LHS < RHS->getNextUnitOffset();
+                       });
+  if (CU != end && (*CU)->getOffset() <= Offset)
     return CU->get();
 
   if (!Parser)
@@ -148,6 +150,7 @@
 
   auto *NewCU = U.get();
   this->insert(CU, std::move(U));
+  ++NumInfoUnits;
   return NewCU;
 }