[libc-commits] [PATCH] D129808: [libc] add unsafe mode to strlen
Michael Jones via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Jul 15 11:29:56 PDT 2022
michaelrj added inline comments.
================
Comment at: libc/src/string/CMakeLists.txt:11
.memory_utils.memset_implementation
+ FLAGS
+ LLVM_LIBC_STRLEN_UNSAFE
----------------
lntue wrote:
> sivachandra wrote:
> > I do not think this will do anything at all without a flag applier implemented somewhere. Also, can we consider a design without the FLAGS feature for comparison?
> To make `FLAGS` property become a compile flag, you'll need to update `_get_common_compile_options` at https://github.com/llvm/llvm-project/blob/main/libc/cmake/modules/LLVMLibCObjectRules.cmake#L3 similar to `FMA_OPT`. In your case the compile option to be append should be `-DLLVM_LIBC_STRLEN_UNSAFE` for gcc/clang and `/DLLVM_LIBC_STRLEN_UNSAFE` for MSVC.
I'm not sure what you mean by "a design without the FLAGS feature", do you mean just having the flag in the code and letting users add it to their build manually?
================
Comment at: libc/src/string/string_utils.h:22
+template <typename T> constexpr T repeat_byte(T byte) {
+ constexpr size_t BITS_IN_BYTE = 8;
+ T result = 0;
----------------
tschuett wrote:
> It is set in stone that a byte has 8 bits for all llvm-libc variants? In LLVM there is always somebody with other ideas.
Yes. 1 byte is 8 bits is true for all supported platforms.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129808/new/
https://reviews.llvm.org/D129808
More information about the libc-commits
mailing list