diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 94468140a30b9..5fd30eccb45c5 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -109,7 +109,9 @@ void MCObjectStreamer::addSpecialFragment(MCFragment *Frag) { void MCObjectStreamer::appendContents(ArrayRef Contents) { ensureHeadroom(Contents.size()); assert(FragSpace >= Contents.size()); - llvm::copy(Contents, getCurFragEnd()); + // As this is performance-sensitive code, explicitly use std::memcpy. + // Optimization of std::copy to memmove is unreliable. + std::memcpy(getCurFragEnd(), Contents.begin(), Contents.size()); CurFrag->FixedSize += Contents.size(); FragSpace -= Contents.size(); }