[libc-commits] [PATCH] D115542: [libc] fix memcpy builtin looping
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Sun Dec 12 15:01:53 PST 2021
sivachandra added inline comments.
================
Comment at: libc/src/string/memory_utils/elements.h:515
-#elif __has_builtin(__builtin_memcpy)
- __builtin_memcpy(dst, src, SIZE);
#else
----------------
gchatelet wrote:
> sivachandra wrote:
> > This should be sufficient to fix the problem.
> Yes but I think that the functions embedding `inline_memcpy` via [[ https://github.com/llvm/llvm-project/blob/main/libc/src/string/memory_utils/memcpy_implementations.h | memcpy_implementations.h ]] should still be marked `-fno-builtin-memcpy` overwise clang might still detect the copy for loop as `memcpy` and call it instead of embedding it.
>
> To be safe we should have all string functions marked with `-fno-builtin`. This would prevent the recursive call for all of `memmove`, `memcmp`, `memset`, etc.
<some function which is not `memcpy`> => inline_memcpy => `memcpy` - This scenario will not lead to a recursive call to `memcpy`.
If we do not want string functions in general to call the memory primitives (`memcpy` and friends), we should of course use `-fno-builtin`. But, do we really want that in general?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D115542/new/
https://reviews.llvm.org/D115542
More information about the libc-commits
mailing list