diff --git a/llvm/tools/llvm-mt/llvm-mt.cpp b/llvm/tools/llvm-mt/llvm-mt.cpp --- a/llvm/tools/llvm-mt/llvm-mt.cpp +++ b/llvm/tools/llvm-mt/llvm-mt.cpp @@ -150,9 +150,11 @@ bool Same = false; if (OutBuffOrErr) { const std::unique_ptr &FileBuffer = *OutBuffOrErr; - Same = std::equal(OutputBuffer->getBufferStart(), - OutputBuffer->getBufferEnd(), - FileBuffer->getBufferStart()); + bool SameSize = + OutputBuffer->getBufferSize() == FileBuffer->getBufferSize(); + Same = SameSize && std::equal(OutputBuffer->getBufferStart(), + OutputBuffer->getBufferEnd(), + FileBuffer->getBufferStart()); } if (!Same) { #if LLVM_ON_UNIX