From c9b39e6bddbf4e10d8358c7c4300c69814a501e1 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 1 Mar 2016 21:24:04 +0000 Subject: [PATCH] Revert "llvm-dwp: Keep ObjectFiles alive until object emission their contents can be referenced directly rather than copied" Accidentally committed. This reverts commit r262389. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@262395 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-dwp/llvm-dwp.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp index 131d5b313a3..ceadfb1b9ee 100644 --- a/tools/llvm-dwp/llvm-dwp.cpp +++ b/tools/llvm-dwp/llvm-dwp.cpp @@ -358,17 +358,11 @@ static std::error_code write(MCStreamer &Out, ArrayRef Inputs) { uint32_t ContributionOffsets[8] = {}; - SmallVector, 128> Objects; - Objects.reserve(Inputs.size()); for (const auto &Input : Inputs) { auto ErrOrObj = object::ObjectFile::createObjectFile(Input); if (!ErrOrObj) return ErrOrObj.getError(); - Objects.push_back(std::move(*ErrOrObj)); - - auto &Obj = *Objects.back().getBinary(); - UnitIndexEntry CurEntry = {}; StringRef CurStrSection; @@ -381,7 +375,7 @@ static std::error_code write(MCStreamer &Out, ArrayRef Inputs) { SmallVector, 4> UncompressedSections; - for (const auto &Section : Obj.sections()) { + for (const auto &Section : ErrOrObj->getBinary()->sections()) { if (Section.isBSS()) continue; if (Section.isVirtual()) @@ -458,7 +452,8 @@ static std::error_code write(MCStreamer &Out, ArrayRef Inputs) { if (!CurCUIndexSection.empty()) { DWARFUnitIndex CUIndex(DW_SECT_INFO); - DataExtractor CUIndexData(CurCUIndexSection, Obj.isLittleEndian(), 0); + DataExtractor CUIndexData(CurCUIndexSection, + ErrOrObj->getBinary()->isLittleEndian(), 0); if (!CUIndex.parse(CUIndexData)) return make_error_code(std::errc::invalid_argument); @@ -496,7 +491,8 @@ static std::error_code write(MCStreamer &Out, ArrayRef Inputs) { if (CurTUIndexSection.empty()) return make_error_code(std::errc::invalid_argument); DWARFUnitIndex TUIndex(DW_SECT_TYPES); - DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian(), 0); + DataExtractor TUIndexData(CurTUIndexSection, + ErrOrObj->getBinary()->isLittleEndian(), 0); if (!TUIndex.parse(TUIndexData)) return make_error_code(std::errc::invalid_argument); addAllTypesFromDWP(Out, TypeIndexEntries, TUIndex, TypesSection, @@ -541,7 +537,7 @@ static std::error_code write(MCStreamer &Out, ArrayRef Inputs) { writeIndex(Out, MCOFI.getDwarfCUIndexSection(), ContributionOffsets, IndexEntries); - Out.Finish(); + return std::error_code(); } @@ -612,4 +608,6 @@ int main(int argc, char **argv) { if (auto Err = write(*MS, InputFiles)) return error(Err.message(), "Writing DWP file"); + + MS->Finish(); }