[compiler-rt] [llvm] [nsan] Emit calls to optimized functions (PR #98900)

Dmitriy Chestnykh via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 22:34:26 PDT 2024


================
@@ -64,13 +62,33 @@ __nsan_copy_values(const u8 *daddr, const u8 *saddr, uptr size) {
                    size * kShadowScale);
 }
 
-// FIXME: We could provide fixed-size versions that would nicely
-// vectorize for known sizes.
+#define NSAN_COPY_VALUES_N(N)                                                  \
+  extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __nsan_copy_##N(               \
+      const u8 *daddr, const u8 *saddr) {                                      \
+    __builtin_memmove((void *)GetShadowTypeAddrFor(daddr),                     \
+                      GetShadowTypeAddrFor(saddr), N);                         \
+    __builtin_memmove((void *)GetShadowAddrFor(daddr),                         \
+                      GetShadowAddrFor(saddr), N *kShadowScale);               \
----------------
chestnykh wrote:

Here clang-format failed to format the code correctly.
`N *kShadowScale` means 'pointer of type N' when we have multiplication here.
https://github.com/llvm/llvm-project/issues/99271

https://github.com/llvm/llvm-project/pull/98900


More information about the llvm-commits mailing list