[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
Wed Jan 6 04:05:55 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa9db51ef69f: [libc] Align src buffer instead of dst buffer (authored by gchatelet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93457/new/
https://reviews.llvm.org/D93457
Files:
libc/src/string/memory_utils/memcpy_utils.h
libc/test/src/string/memory_utils/memcpy_utils_test.cpp
Index: libc/test/src/string/memory_utils/memcpy_utils_test.cpp
===================================================================
--- libc/test/src/string/memory_utils/memcpy_utils_test.cpp
+++ libc/test/src/string/memory_utils/memcpy_utils_test.cpp
@@ -162,14 +162,14 @@
TEST(MemcpyUtilsTest, CopyAlignedBlocks) {
auto &trace = GetTrace();
- // Destination is aligned and multiple of alignment.
+ // Source is aligned and multiple of alignment.
// "1111"
trace.Clear();
CopyAlignedBlocks<4>(I(0), I(0), 4);
EXPECT_STREQ(trace.Write(), "2222");
EXPECT_STREQ(trace.Read(), "2222");
- // Destination is aligned and multiple of alignment.
+ // Source is aligned and multiple of alignment.
// "11110000"
// + "00001111"
// = "11111111"
@@ -178,7 +178,7 @@
EXPECT_STREQ(trace.Write(), "11111111");
EXPECT_STREQ(trace.Read(), "11111111");
- // Destination is aligned already overlap at end.
+ // Source is aligned already overlap at end.
// "1111000000000"
// + "0000111100000"
// + "0000000011110"
@@ -189,26 +189,26 @@
EXPECT_STREQ(trace.Write(), "1111111112221");
EXPECT_STREQ(trace.Read(), "1111111112221");
- // Misaligned destination.
+ // Misaligned source.
// "01111000000000"
// + "00001111000000"
// + "00000000111100"
// + "00000000001111"
// = "01112111112211"
trace.Clear();
- CopyAlignedBlocks<4>(I(1), I(0), 13);
- EXPECT_STREQ(trace.Write(), "01112111112211");
- EXPECT_STREQ(trace.Read(), "1112111112211");
+ CopyAlignedBlocks<4>(I(0), I(1), 13);
+ EXPECT_STREQ(trace.Write(), "1112111112211");
+ EXPECT_STREQ(trace.Read(), "01112111112211");
- // Misaligned destination aligned at end.
+ // Misaligned source aligned at end.
// "011110000000"
// + "000011110000"
// + "000000001111"
// = "011121111111"
trace.Clear();
- CopyAlignedBlocks<4>(I(1), I(0), 11);
- EXPECT_STREQ(trace.Write(), "011121111111");
- EXPECT_STREQ(trace.Read(), "11121111111");
+ CopyAlignedBlocks<4>(I(0), I(1), 11);
+ EXPECT_STREQ(trace.Write(), "11121111111");
+ EXPECT_STREQ(trace.Read(), "011121111111");
}
TEST(MemcpyUtilsTest, MaxReloads) {
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.314852.patch
Type: text/x-patch
Size: 2805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210106/b9d6dac8/attachment-0001.bin>
More information about the libc-commits
mailing list