[compiler-rt] [ASan] Update meminstrinsics to use library memmove rather than internal (PR #160740)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 25 10:07:57 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Dan Blackwell (DanBlackwell)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/160740.diff
2 Files Affected:
- (modified) compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp (+3-1)
- (modified) compiler-rt/lib/asan/asan_interceptors_memintrinsics.h (+1)
``````````diff
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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/160740
More information about the llvm-commits
mailing list