[compiler-rt] eaf36c6 - [ASan] Update meminstrinsics to use library memmove rather than internal (#160740)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 26 05:33:02 PDT 2025
Author: Dan Blackwell
Date: 2025-09-26T13:32:58+01:00
New Revision: eaf36c668c956a90bfb00c47415c4c8550f159c8
URL: https://github.com/llvm/llvm-project/commit/eaf36c668c956a90bfb00c47415c4c8550f159c8
DIFF: https://github.com/llvm/llvm-project/commit/eaf36c668c956a90bfb00c47415c4c8550f159c8.diff
LOG: [ASan] Update meminstrinsics to use library memmove rather than internal (#160740)
Currently `memcpy` and `memset` intrinsics map through to the library
implementations if ASan has been inited, whereas `memmove` always calls
`internal_memmove`.
This patch changes `memmove` to use the library implementation if ASan
has been inited.
Added:
Modified:
compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
compiler-rt/lib/asan/asan_interceptors_memintrinsics.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp b/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
index bdf328f892063..f52ae9ae8d17c 100644
--- a/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
@@ -55,8 +55,10 @@ using namespace __asan;
if (LIKELY(replace_intrin_cached)) { \
ASAN_READ_RANGE(ctx, from, size); \
ASAN_WRITE_RANGE(ctx, to, size); \
+ } else if (UNLIKELY(!AsanInited())) { \
+ return internal_memmove(to, from, size); \
} \
- return internal_memmove(to, from, size); \
+ return REAL(memmove)(to, from, size); \
} while (0)
void *__asan_memcpy(void *to, const void *from, uptr size) {
diff --git a/compiler-rt/lib/asan/asan_interceptors_memintrinsics.h b/compiler-rt/lib/asan/asan_interceptors_memintrinsics.h
index 14727a5d665ed..ec988cff51c59 100644
--- a/compiler-rt/lib/asan/asan_interceptors_memintrinsics.h
+++ b/compiler-rt/lib/asan/asan_interceptors_memintrinsics.h
@@ -20,6 +20,7 @@
DECLARE_REAL(void *, memcpy, void *to, const void *from, SIZE_T size)
DECLARE_REAL(void *, memset, void *block, int c, SIZE_T size)
+DECLARE_REAL(void *, memmove, void *to, const void *from, SIZE_T size)
namespace __asan {
More information about the llvm-commits
mailing list