Index: include/llvm/MC/MCFragment.h =================================================================== --- include/llvm/MC/MCFragment.h +++ include/llvm/MC/MCFragment.h @@ -168,6 +168,8 @@ template class MCEncodedFragmentWithContents : public MCEncodedFragment { SmallVector Contents; + SmallVector Refs; + size_t Size = 0; protected: MCEncodedFragmentWithContents(MCFragment::FragmentType FType, @@ -175,9 +177,53 @@ MCSection *Sec) : MCEncodedFragment(FType, HasInstructions, Sec) {} + void collapse() { + assert(Contents.empty() || Refs.empty()); + for (StringRef R : Refs) + Contents.append(R.begin(), R.end()); + Refs.clear(); + Size = 0; + } + public: - SmallVectorImpl &getContents() { return Contents; } - const SmallVectorImpl &getContents() const { return Contents; } + size_t getSize() const { return !Refs.empty() ? Size : Contents.size(); } + MutableArrayRef getMutableContents() { return Contents; } + void appendByReference(StringRef Str) { + assert(Contents.empty()); + Refs.push_back(Str); + Size += Str.size(); + } + void append(StringRef Str) { + collapse(); + Contents.append(Str.begin(), Str.end()); + } + void append(const MCEncodedFragmentWithContents &Frag) { + collapse(); + Contents.append(Frag.Contents.begin(), Frag.Contents.end()); + } + void clear() { + Contents.clear(); + Refs.clear(); + Size = 0; + } + void appendZeros(size_t Count) { + collapse(); + Contents.resize(Contents.size() + Count); + } + template void forEachByte(Functor F) const { + forEachChunk([&](StringRef Str) { + for (char c : Str) + F(c); + }); + } + template void forEachChunk(Functor F) const { + if (Refs.empty()) { + F(StringRef(Contents.data(), Contents.size())); + return; + } + for (StringRef R : Refs) + F(R); + } }; /// Interface implemented by fragments that contain encoded instructions and/or Index: include/llvm/MC/MCObjectStreamer.h =================================================================== --- include/llvm/MC/MCObjectStreamer.h +++ include/llvm/MC/MCObjectStreamer.h @@ -107,6 +107,7 @@ void EmitBundleLock(bool AlignToEnd) override; void EmitBundleUnlock() override; void EmitBytes(StringRef Data) override; + void EmitBytesByReference(StringRef Data) override; void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, unsigned ValueSize = 1, unsigned MaxBytesToEmit = 0) override; Index: include/llvm/MC/MCStreamer.h =================================================================== --- include/llvm/MC/MCStreamer.h +++ include/llvm/MC/MCStreamer.h @@ -517,6 +517,8 @@ /// etc. virtual void EmitBytes(StringRef Data); + virtual void EmitBytesByReference(StringRef Data) { return EmitBytes(Data); } + /// \brief Emit the expression \p Value into the output as a native /// integer of the given \p Size bytes. /// Index: lib/MC/MCAssembler.cpp =================================================================== --- lib/MC/MCAssembler.cpp +++ lib/MC/MCAssembler.cpp @@ -246,11 +246,11 @@ const MCFragment &F) const { switch (F.getKind()) { case MCFragment::FT_Data: - return cast(F).getContents().size(); + return cast(F).getSize(); case MCFragment::FT_Relaxable: - return cast(F).getContents().size(); + return cast(F).getSize(); case MCFragment::FT_CompactEncodedInst: - return cast(F).getContents().size(); + return cast(F).getSize(); case MCFragment::FT_Fill: return cast(F).getSize(); @@ -304,7 +304,7 @@ case MCFragment::FT_CVInlineLines: return cast(F).getContents().size(); case MCFragment::FT_CVDefRange: - return cast(F).getContents().size(); + return cast(F).getSize(); case MCFragment::FT_Dummy: llvm_unreachable("Should not have been added"); } @@ -477,17 +477,20 @@ case MCFragment::FT_Data: ++stats::EmittedDataFragments; - OW->writeBytes(cast(F).getContents()); + cast(F).forEachChunk( + [&](StringRef Chunk) { OW->writeBytes(Chunk); }); break; case MCFragment::FT_Relaxable: ++stats::EmittedRelaxableFragments; - OW->writeBytes(cast(F).getContents()); + cast(F).forEachChunk( + [&](StringRef Str) { OW->writeBytes(Str); }); break; case MCFragment::FT_CompactEncodedInst: ++stats::EmittedCompactEncodedInstFragments; - OW->writeBytes(cast(F).getContents()); + cast(F).forEachChunk( + [&](StringRef Str) { OW->writeBytes(Str); }); break; case MCFragment::FT_Fill: { @@ -548,8 +551,8 @@ break; } case MCFragment::FT_CVDefRange: { - const auto &DRF = cast(F); - OW->writeBytes(DRF.getContents()); + cast(F).forEachChunk( + [&](StringRef Str) { OW->writeBytes(Str); }); break; } case MCFragment::FT_Dummy: @@ -577,14 +580,15 @@ const MCDataFragment &DF = cast(F); assert(DF.fixup_begin() == DF.fixup_end() && "Cannot have fixups in virtual section!"); - for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i) - if (DF.getContents()[i]) { + DF.forEachByte([&](char c) { + if (c) { if (auto *ELFSec = dyn_cast(Sec)) report_fatal_error("non-zero initializer found in section '" + ELFSec->getSectionName() + "'"); else report_fatal_error("non-zero initializer found in virtual section"); } + }); break; } case MCFragment::FT_Align: @@ -693,13 +697,13 @@ MutableArrayRef Contents; if (auto *FragWithFixups = dyn_cast(&Frag)) { Fixups = FragWithFixups->getFixups(); - Contents = FragWithFixups->getContents(); + Contents = FragWithFixups->getMutableContents(); } else if (auto *FragWithFixups = dyn_cast(&Frag)) { Fixups = FragWithFixups->getFixups(); - Contents = FragWithFixups->getContents(); + Contents = FragWithFixups->getMutableContents(); } else if (auto *FragWithFixups = dyn_cast(&Frag)) { Fixups = FragWithFixups->getFixups(); - Contents = FragWithFixups->getContents(); + Contents = FragWithFixups->getMutableContents(); } else llvm_unreachable("Unknown fragment with fixups!"); for (const MCFixup &Fixup : Fixups) { @@ -778,7 +782,8 @@ // Update the fragment. F.setInst(Relaxed); - F.getContents() = Code; + F.clear(); + F.append(Code); F.getFixups() = Fixups; return true; @@ -842,9 +847,9 @@ bool MCAssembler::relaxCVDefRange(MCAsmLayout &Layout, MCCVDefRangeFragment &F) { - unsigned OldSize = F.getContents().size(); + unsigned OldSize = F.getSize(); getContext().getCVContext().encodeDefRange(Layout, F); - return OldSize != F.getContents().size(); + return OldSize != F.getSize(); } bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSection &Sec) { Index: lib/MC/MCCodeView.cpp =================================================================== --- lib/MC/MCCodeView.cpp +++ lib/MC/MCCodeView.cpp @@ -68,20 +68,19 @@ if (!StrTabFragment) { StrTabFragment = new MCDataFragment(); // Start a new string table out with a null byte. - StrTabFragment->getContents().push_back('\0'); + StrTabFragment->append(StringRef("\0", 1)); } return StrTabFragment; } StringRef CodeViewContext::addToStringTable(StringRef S) { - SmallVectorImpl &Contents = getStringTableFragment()->getContents(); - auto Insertion = - StringTable.insert(std::make_pair(S, unsigned(Contents.size()))); + auto &Frag = *getStringTableFragment(); + auto Insertion = StringTable.insert(std::make_pair(S, Frag.getSize())); // Return the string from the table, since it is stable. S = Insertion.first->first(); if (Insertion.second) { // The string map key is always null terminated. - Contents.append(S.begin(), S.end() + 1); + Frag.append(StringRef(S.begin(), S.size() + 1)); } return S; } @@ -369,8 +368,7 @@ void CodeViewContext::encodeDefRange(MCAsmLayout &Layout, MCCVDefRangeFragment &Frag) { MCContext &Ctx = Layout.getAssembler().getContext(); - SmallVectorImpl &Contents = Frag.getContents(); - Contents.clear(); + SmallVector Contents; SmallVectorImpl &Fixups = Frag.getFixups(); Fixups.clear(); raw_svector_ostream OS(Contents); @@ -416,6 +414,8 @@ RangeSize -= Chunk; } while (RangeSize > 0); } + Frag.clear(); + Frag.append(StringRef(Contents.begin(), Contents.size())); } // Index: lib/MC/MCELFStreamer.cpp =================================================================== --- lib/MC/MCELFStreamer.cpp +++ lib/MC/MCELFStreamer.cpp @@ -49,13 +49,13 @@ MCAssembler &Assembler = getAssembler(); if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) { - uint64_t FSize = EF->getContents().size(); + uint64_t FSize = EF->getSize(); if (FSize > Assembler.getBundleAlignSize()) report_fatal_error("Fragment can't be larger than a bundle size"); - uint64_t RequiredBundlePadding = computeBundlePadding( - Assembler, EF, DF->getContents().size(), FSize); + uint64_t RequiredBundlePadding = + computeBundlePadding(Assembler, EF, DF->getSize(), FSize); if (RequiredBundlePadding > UINT8_MAX) report_fatal_error("Padding cannot exceed 255 bytes"); @@ -70,19 +70,19 @@ Assembler.writeFragmentPadding(*EF, FSize, OW); delete OW; - DF->getContents().append(Code.begin(), Code.end()); + DF->append(Code); } } - flushPendingLabels(DF, DF->getContents().size()); + flushPendingLabels(DF, DF->getSize()); for (unsigned i = 0, e = EF->getFixups().size(); i != e; ++i) { EF->getFixups()[i].setOffset(EF->getFixups()[i].getOffset() + - DF->getContents().size()); + DF->getSize()); DF->getFixups().push_back(EF->getFixups()[i]); } DF->setHasInstructions(true); - DF->getContents().append(EF->getContents().begin(), EF->getContents().end()); + DF->append(*EF); } void MCELFStreamer::InitSections(bool NoExecStack) { @@ -518,7 +518,7 @@ // there are no fixups registered. MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment(); insert(CEIF); - CEIF->getContents().append(Code.begin(), Code.end()); + CEIF->append(Code); return; } else { DF = new MCDataFragment(); @@ -541,11 +541,11 @@ // Add the fixups and data. for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { - Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); + Fixups[i].setOffset(Fixups[i].getOffset() + DF->getSize()); DF->getFixups().push_back(Fixups[i]); } DF->setHasInstructions(true); - DF->getContents().append(Code.begin(), Code.end()); + DF->append(Code); if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) { if (!isBundleLocked()) { Index: lib/MC/MCFragment.cpp =================================================================== --- lib/MC/MCFragment.cpp +++ lib/MC/MCFragment.cpp @@ -317,6 +317,21 @@ } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) +template +static void +dumpContents(raw_ostream &OS, + const MCEncodedFragmentWithContents &Frag) { + OS << "\n "; + OS << " Contents:["; + bool first = true; + Frag.forEachByte([&](char c) { + if (!first) + OS << ','; + first = false; + OS << hexdigit((c >> 4) & 0xF) << hexdigit(c & 0xF); + }); + OS << "] (" << Frag.getSize() << " bytes)"; +} LLVM_DUMP_METHOD void MCFragment::dump() { raw_ostream &OS = llvm::errs(); @@ -356,14 +371,7 @@ } case MCFragment::FT_Data: { const MCDataFragment *DF = cast(this); - OS << "\n "; - OS << " Contents:["; - const SmallVectorImpl &Contents = DF->getContents(); - for (unsigned i = 0, e = Contents.size(); i != e; ++i) { - if (i) OS << ","; - OS << hexdigit((Contents[i] >> 4) & 0xF) << hexdigit(Contents[i] & 0xF); - } - OS << "] (" << Contents.size() << " bytes)"; + dumpContents(OS, *DF); if (DF->fixup_begin() != DF->fixup_end()) { OS << ",\n "; @@ -381,13 +389,7 @@ const MCCompactEncodedInstFragment *CEIF = cast(this); OS << "\n "; - OS << " Contents:["; - const SmallVectorImpl &Contents = CEIF->getContents(); - for (unsigned i = 0, e = Contents.size(); i != e; ++i) { - if (i) OS << ","; - OS << hexdigit((Contents[i] >> 4) & 0xF) << hexdigit(Contents[i] & 0xF); - } - OS << "] (" << Contents.size() << " bytes)"; + dumpContents(OS, *CEIF); break; } case MCFragment::FT_Fill: { Index: lib/MC/MCMachOStreamer.cpp =================================================================== --- lib/MC/MCMachOStreamer.cpp +++ lib/MC/MCMachOStreamer.cpp @@ -440,10 +440,10 @@ // Add the fixups and data. for (MCFixup &Fixup : Fixups) { - Fixup.setOffset(Fixup.getOffset() + DF->getContents().size()); + Fixup.setOffset(Fixup.getOffset() + DF->getSize()); DF->getFixups().push_back(Fixup); } - DF->getContents().append(Code.begin(), Code.end()); + DF->append(Code); } void MCMachOStreamer::FinishImpl() { Index: lib/MC/MCObjectStreamer.cpp =================================================================== --- lib/MC/MCObjectStreamer.cpp +++ lib/MC/MCObjectStreamer.cpp @@ -123,7 +123,7 @@ SMLoc Loc) { MCStreamer::EmitValueImpl(Value, Size, Loc); MCDataFragment *DF = getOrCreateDataFragment(); - flushPendingLabels(DF, DF->getContents().size()); + flushPendingLabels(DF, DF->getSize()); MCCVLineEntry::Make(this); MCDwarfLineEntry::Make(this, getCurrentSection().first); @@ -134,10 +134,9 @@ EmitIntValue(AbsValue, Size); return; } - DF->getFixups().push_back( - MCFixup::create(DF->getContents().size(), Value, - MCFixup::getKindForSize(Size, false), Loc)); - DF->getContents().resize(DF->getContents().size() + Size, 0); + DF->getFixups().push_back(MCFixup::create( + DF->getSize(), Value, MCFixup::getKindForSize(Size, false), Loc)); + DF->appendZeros(Size); } void MCObjectStreamer::EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame) { @@ -163,7 +162,7 @@ if (F && !(getAssembler().isBundlingEnabled() && getAssembler().getRelaxAll())) { Symbol->setFragment(F); - Symbol->setOffset(F->getContents().size()); + Symbol->setOffset(F->getSize()); } else { PendingLabels.push_back(Symbol); } @@ -276,7 +275,7 @@ raw_svector_ostream VecOS(Code); getAssembler().getEmitter().encodeInstruction(Inst, VecOS, IF->getFixups(), STI); - IF->getContents().append(Code.begin(), Code.end()); + IF->append(Code); } #ifndef NDEBUG @@ -415,8 +414,16 @@ MCCVLineEntry::Make(this); MCDwarfLineEntry::Make(this, getCurrentSection().first); MCDataFragment *DF = getOrCreateDataFragment(); - flushPendingLabels(DF, DF->getContents().size()); - DF->getContents().append(Data.begin(), Data.end()); + flushPendingLabels(DF, DF->getSize()); + DF->append(Data); +} + +void MCObjectStreamer::EmitBytesByReference(StringRef Data) { + MCCVLineEntry::Make(this); + MCDwarfLineEntry::Make(this, getCurrentSection().first); + MCDataFragment *DF = getOrCreateDataFragment(); + flushPendingLabels(DF, DF->getSize()); + DF->appendByReference(Data); } void MCObjectStreamer::EmitValueToAlignment(unsigned ByteAlignment, @@ -447,21 +454,19 @@ // Associate GPRel32 fixup with data and resize data area void MCObjectStreamer::EmitGPRel32Value(const MCExpr *Value) { MCDataFragment *DF = getOrCreateDataFragment(); - flushPendingLabels(DF, DF->getContents().size()); + flushPendingLabels(DF, DF->getSize()); - DF->getFixups().push_back(MCFixup::create(DF->getContents().size(), - Value, FK_GPRel_4)); - DF->getContents().resize(DF->getContents().size() + 4, 0); + DF->getFixups().push_back(MCFixup::create(DF->getSize(), Value, FK_GPRel_4)); + DF->appendZeros(4); } // Associate GPRel32 fixup with data and resize data area void MCObjectStreamer::EmitGPRel64Value(const MCExpr *Value) { MCDataFragment *DF = getOrCreateDataFragment(); - flushPendingLabels(DF, DF->getContents().size()); + flushPendingLabels(DF, DF->getSize()); - DF->getFixups().push_back(MCFixup::create(DF->getContents().size(), - Value, FK_GPRel_4)); - DF->getContents().resize(DF->getContents().size() + 8, 0); + DF->getFixups().push_back(MCFixup::create(DF->getSize(), Value, FK_GPRel_4)); + DF->appendZeros(8); } bool MCObjectStreamer::EmitRelocDirective(const MCExpr &Offset, StringRef Name, @@ -474,7 +479,7 @@ llvm_unreachable("Offset is negative"); MCDataFragment *DF = getOrCreateDataFragment(); - flushPendingLabels(DF, DF->getContents().size()); + flushPendingLabels(DF, DF->getSize()); Optional MaybeKind = Assembler->getBackend().getFixupKind(Name); if (!MaybeKind.hasValue()) Index: lib/MC/WinCOFFStreamer.cpp =================================================================== --- lib/MC/WinCOFFStreamer.cpp +++ lib/MC/WinCOFFStreamer.cpp @@ -52,11 +52,11 @@ // Add the fixups and data. for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { - Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); + Fixups[i].setOffset(Fixups[i].getOffset() + DF->getSize()); DF->getFixups().push_back(Fixups[i]); } - DF->getContents().append(Code.begin(), Code.end()); + DF->append(Code); } void MCWinCOFFStreamer::InitSections(bool NoExecStack) { @@ -194,17 +194,17 @@ void MCWinCOFFStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) { MCDataFragment *DF = getOrCreateDataFragment(); const MCSymbolRefExpr *SRE = MCSymbolRefExpr::create(Symbol, getContext()); - MCFixup Fixup = MCFixup::create(DF->getContents().size(), SRE, FK_SecRel_2); + MCFixup Fixup = MCFixup::create(DF->getSize(), SRE, FK_SecRel_2); DF->getFixups().push_back(Fixup); - DF->getContents().resize(DF->getContents().size() + 2, 0); + DF->appendZeros(2); } void MCWinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) { MCDataFragment *DF = getOrCreateDataFragment(); const MCSymbolRefExpr *SRE = MCSymbolRefExpr::create(Symbol, getContext()); - MCFixup Fixup = MCFixup::create(DF->getContents().size(), SRE, FK_SecRel_4); + MCFixup Fixup = MCFixup::create(DF->getSize(), SRE, FK_SecRel_4); DF->getFixups().push_back(Fixup); - DF->getContents().resize(DF->getContents().size() + 4, 0); + DF->appendZeros(4); } void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Index: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -1116,8 +1116,7 @@ } void ARMELFStreamer::EmitFixup(const MCExpr *Expr, MCFixupKind Kind) { MCDataFragment *Frag = getOrCreateDataFragment(); - Frag->getFixups().push_back(MCFixup::create(Frag->getContents().size(), Expr, - Kind)); + Frag->getFixups().push_back(MCFixup::create(Frag->getSize(), Expr, Kind)); } void ARMELFStreamer::EHReset() { @@ -1204,8 +1203,7 @@ visitUsedExpr(*PersonalityRef); MCDataFragment *DF = getOrCreateDataFragment(); - DF->getFixups().push_back(MCFixup::create(DF->getContents().size(), - PersonalityRef, + DF->getFixups().push_back(MCFixup::create(DF->getSize(), PersonalityRef, MCFixup::getKindForSize(4, false))); } Index: tools/llvm-dwp/llvm-dwp.cpp =================================================================== --- tools/llvm-dwp/llvm-dwp.cpp +++ tools/llvm-dwp/llvm-dwp.cpp @@ -1,3 +1,4 @@ +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringSet.h" @@ -23,8 +24,8 @@ #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" -#include #include +#include #include #include #include @@ -49,7 +50,7 @@ } static std::error_code -writeStringsAndOffsets(MCStreamer &Out, StringMap &Strings, +writeStringsAndOffsets(MCStreamer &Out, DenseMap &Strings, uint32_t &StringOffset, MCSection *StrSection, MCSection *StrOffsetSection, StringRef CurStrSection, StringRef CurStrOffsetSection) { @@ -68,8 +69,7 @@ auto Pair = Strings.insert(std::make_pair(Str, StringOffset)); if (Pair.second) { Out.SwitchSection(StrSection); - Out.EmitBytes( - StringRef(Pair.first->getKeyData(), Pair.first->getKeyLength() + 1)); + Out.EmitBytesByReference(StringRef(Str.data(), Str.size() + 1)); StringOffset += Str.size() + 1; } OffsetRemapping[PrevOffset] = Pair.first->second; @@ -209,7 +209,7 @@ ++I; } auto &C = Entry.Contributions[DW_SECT_TYPES - DW_SECT_INFO]; - Out.EmitBytes(Types.substr( + Out.EmitBytesByReference(Types.substr( C.Offset - TUEntry.Contributions[DW_SECT_TYPES - DW_SECT_INFO].Offset, C.Length)); C.Offset = TypesOffset; @@ -247,7 +247,7 @@ if (!P.second) continue; - Out.EmitBytes(Types.substr(PrevOffset, C.Length)); + Out.EmitBytesByReference(Types.substr(PrevOffset, C.Length)); TypesOffset += C.Length; } } @@ -353,16 +353,24 @@ MapVector IndexEntries; MapVector TypeIndexEntries; - StringMap Strings; + DenseMap Strings; uint32_t StringOffset = 0; uint32_t ContributionOffsets[8] = {}; + SmallVector, 4> UncompressedSections; + + 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; @@ -373,9 +381,7 @@ StringRef CurCUIndexSection; StringRef CurTUIndexSection; - SmallVector, 4> UncompressedSections; - - for (const auto &Section : ErrOrObj->getBinary()->sections()) { + for (const auto &Section : Obj.sections()) { if (Section.isBSS()) continue; if (Section.isVirtual()) @@ -443,7 +449,7 @@ CurTUIndexSection = Contents; else { Out.SwitchSection(OutSection); - Out.EmitBytes(Contents); + Out.EmitBytesByReference(Contents); } } @@ -452,8 +458,7 @@ if (!CurCUIndexSection.empty()) { DWARFUnitIndex CUIndex(DW_SECT_INFO); - DataExtractor CUIndexData(CurCUIndexSection, - ErrOrObj->getBinary()->isLittleEndian(), 0); + DataExtractor CUIndexData(CurCUIndexSection, Obj.isLittleEndian(), 0); if (!CUIndex.parse(CUIndexData)) return make_error_code(std::errc::invalid_argument); @@ -491,8 +496,7 @@ if (CurTUIndexSection.empty()) return make_error_code(std::errc::invalid_argument); DWARFUnitIndex TUIndex(DW_SECT_TYPES); - DataExtractor TUIndexData(CurTUIndexSection, - ErrOrObj->getBinary()->isLittleEndian(), 0); + DataExtractor TUIndexData(CurTUIndexSection, Obj.isLittleEndian(), 0); if (!TUIndex.parse(TUIndexData)) return make_error_code(std::errc::invalid_argument); addAllTypesFromDWP(Out, TypeIndexEntries, TUIndex, TypesSection, @@ -537,7 +541,7 @@ writeIndex(Out, MCOFI.getDwarfCUIndexSection(), ContributionOffsets, IndexEntries); - + Out.Finish(); return std::error_code(); } @@ -608,6 +612,4 @@ if (auto Err = write(*MS, InputFiles)) return error(Err.message(), "Writing DWP file"); - - MS->Finish(); }