[llvm-branch-commits] [compiler-rt] [sanitizer] Add MemCpyAccessible (PR #112794)
Florian Mayer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Oct 17 16:53:42 PDT 2024
================
@@ -230,18 +230,18 @@ void MemCpyAccessible(void *dest, const void *src, uptr n) {
uptr e = reinterpret_cast<uptr>(src) + n;
uptr e_down = RoundDownTo(e, page_size);
- auto copy_or_zero = [dest, src](uptr b, uptr e) {
- uptr d = reinterpret_cast<uptr>(dest) + (b - reinterpret_cast<uptr>(src));
- if (!TryMemCpy(reinterpret_cast<void *>(d), reinterpret_cast<void *>(b),
- e - b))
- internal_memset(reinterpret_cast<void *>(d), 0, e - b);
+ const uptr off = reinterpret_cast<uptr>(dest) - b;
+
+ auto copy_or_zero = [off](uptr beg, uptr end) {
+ void *d = reinterpret_cast<void *>(beg + off);
----------------
fmayer wrote:
i preferred the previous calculation, it's weird to have the offset between source and destination.
https://github.com/llvm/llvm-project/pull/112794
More information about the llvm-branch-commits
mailing list