[libc-commits] [PATCH] D93457: [libc] Align src buffer instead of dst buffer

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Dec 17 05:58:04 PST 2020

gchatelet created this revision.
gchatelet added reviewers: avieira, sivachandra.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added a project: libc-project.
gchatelet requested review of this revision.

We used to align destination buffer instead of source buffer for the loop of block copy.
This is a mistake.

  rG LLVM Github Monorepo



Index: libc/src/string/memory_utils/memcpy_utils.h
--- libc/src/string/memory_utils/memcpy_utils.h
+++ libc/src/string/memory_utils/memcpy_utils.h
@@ -90,7 +90,7 @@
   CopyBlock<kBlockSize>(dst, src); // Copy first block
   // Copy aligned blocks
-  const size_t ofla = offset_from_last_aligned<kBlockSize>(dst);
+  const size_t ofla = offset_from_last_aligned<kBlockSize>(src);
   const size_t limit = count + ofla - kBlockSize;
   for (size_t offset = kBlockSize; offset < limit; offset += kBlockSize)
     CopyBlock<kBlockSize>(dst - ofla + offset, src - ofla + offset);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93457.312475.patch
Type: text/x-patch
Size: 644 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20201217/d6920cdd/attachment-0001.bin>

More information about the libc-commits mailing list