Reapply [FastISel][AArch64] Make use of the zero register when possible (r215591).
[oota-llvm.git] / lib / DebugInfo / DWARFUnit.cpp
index 027827735cf65f5c0b120f468942b894c1d85dad..6ed3e04b7bf304c2f42e3851f2d10acfa7949507 100644 (file)
@@ -225,21 +225,20 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
     setBaseAddress(BaseAddr);
     AddrOffsetSectionBase = DieArray[0].getAttributeValueAsSectionOffset(
         this, DW_AT_GNU_addr_base, 0);
-    // Users of old DWARF may not know about DW_AT_ranges_base, so it is ignored
-    // for skeleton CU DIE (e.g. DW_AT_ranges are *not* relative to it).
-    if (Version > 4) {
-      RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset(
-          this, DW_AT_GNU_ranges_base, 0);
-    }
+    RangeSectionBase = DieArray[0].getAttributeValueAsSectionOffset(
+        this, DW_AT_ranges_base, 0);
+    // Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
+    // skeleton CU DIE, so that DWARF users not aware of it are not broken.
   }
 
   setDIERelations();
   return DieArray.size();
 }
 
-DWARFUnit::DWOHolder::DWOHolder(object::ObjectFile *DWOFile)
-    : DWOFile(DWOFile),
-      DWOContext(cast<DWARFContext>(DIContext::getDWARFContext(DWOFile))),
+DWARFUnit::DWOHolder::DWOHolder(std::unique_ptr<object::ObjectFile> DWOFile)
+    : DWOFile(std::move(DWOFile)),
+      DWOContext(
+          cast<DWARFContext>(DIContext::getDWARFContext(*this->DWOFile))),
       DWOU(nullptr) {
   if (DWOContext->getNumDWOCompileUnits() > 0)
     DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
@@ -262,12 +261,12 @@ bool DWARFUnit::parseDWO() {
     sys::path::append(AbsolutePath, CompilationDir);
   }
   sys::path::append(AbsolutePath, DWOFileName);
-  ErrorOr<object::ObjectFile *> DWOFile =
+  ErrorOr<object::OwningBinary<object::ObjectFile>> DWOFile =
       object::ObjectFile::createObjectFile(AbsolutePath);
   if (!DWOFile)
     return false;
   // Reset DWOHolder.
-  DWO.reset(new DWOHolder(DWOFile.get()));
+  DWO = llvm::make_unique<DWOHolder>(std::move(DWOFile->getBinary()));
   DWARFUnit *DWOCU = DWO->getUnit();
   // Verify that compile unit in .dwo file is valid.
   if (!DWOCU || DWOCU->getDWOId() != getDWOId()) {
@@ -276,8 +275,7 @@ bool DWARFUnit::parseDWO() {
   }
   // Share .debug_addr and .debug_ranges section with compile unit in .dwo
   DWOCU->setAddrOffsetSection(AddrOffsetSection, AddrOffsetSectionBase);
-  uint32_t DWORangesBase = DieArray[0].getAttributeValueAsSectionOffset(
-      this, DW_AT_GNU_ranges_base, 0);
+  uint32_t DWORangesBase = DieArray[0].getRangesBaseAttribute(this, 0);
   DWOCU->setRangesSection(RangeSection, DWORangesBase);
   return true;
 }