diff options
Diffstat (limited to 'llvm/lib/MC/MachObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/MachObjectWriter.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp index 3298eef..48d2fc6 100644 --- a/llvm/lib/MC/MachObjectWriter.cpp +++ b/llvm/lib/MC/MachObjectWriter.cpp @@ -797,11 +797,8 @@ uint64_t MachObjectWriter::writeObject() { UndefinedSymbolData); if (!CGProfile.empty()) { - MCSection *CGProfileSection = getContext().getMachOSection( - "__LLVM", "__cg_profile", 0, SectionKind::getMetadata()); - auto &Frag = *CGProfileSection->begin(); - Frag.clearContents(); - raw_svector_ostream OS(Frag.getContentsForAppending()); + SmallString<0> Content; + raw_svector_ostream OS(Content); for (const MCObjectWriter::CGProfileEntry &CGPE : CGProfile) { uint32_t FromIndex = CGPE.From->getSymbol().getIndex(); uint32_t ToIndex = CGPE.To->getSymbol().getIndex(); @@ -809,7 +806,9 @@ uint64_t MachObjectWriter::writeObject() { support::endian::write(OS, ToIndex, W.Endian); support::endian::write(OS, CGPE.Count, W.Endian); } - Frag.doneAppending(); + MCSection *Sec = getContext().getMachOSection("__LLVM", "__cg_profile", 0, + SectionKind::getMetadata()); + llvm::copy(OS.str(), Sec->curFragList()->Head->getContents().data()); } unsigned NumSections = Asm.end() - Asm.begin(); |