diff options
author | Guillaume Chatelet <gchatelet@google.com> | 2023-12-19 13:57:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-19 13:57:44 +0100 |
commit | 64671dbebcd12c2e8e87dac48b382f98b2f15568 (patch) | |
tree | 4e5edf264c98793a269abfc1c8d41e5131efffb3 | |
parent | 92fc4b482f58cb243d982d572adb7a80ceab6945 (diff) | |
download | llvm-64671dbebcd12c2e8e87dac48b382f98b2f15568.zip llvm-64671dbebcd12c2e8e87dac48b382f98b2f15568.tar.gz llvm-64671dbebcd12c2e8e87dac48b382f98b2f15568.tar.bz2 |
[libc] Remove unnecessary call in memfunction dispatchers (#75800)
Before this patch the compiler could generate unnecessary calls to the
selected implementation.
https://clang.llvm.org/docs/AttributeReference.html#flatten
-rw-r--r-- | libc/src/string/memory_utils/inline_bcmp.h | 3 | ||||
-rw-r--r-- | libc/src/string/memory_utils/inline_bzero.h | 4 | ||||
-rw-r--r-- | libc/src/string/memory_utils/inline_memcmp.h | 3 | ||||
-rw-r--r-- | libc/src/string/memory_utils/inline_memcpy.h | 4 | ||||
-rw-r--r-- | libc/src/string/memory_utils/inline_memmove.h | 8 |
5 files changed, 12 insertions, 10 deletions
diff --git a/libc/src/string/memory_utils/inline_bcmp.h b/libc/src/string/memory_utils/inline_bcmp.h index b1c981d..69aa2ac 100644 --- a/libc/src/string/memory_utils/inline_bcmp.h +++ b/libc/src/string/memory_utils/inline_bcmp.h @@ -32,7 +32,8 @@ namespace LIBC_NAMESPACE { -LIBC_INLINE int inline_bcmp(const void *p1, const void *p2, size_t count) { +[[gnu::flatten]] LIBC_INLINE int inline_bcmp(const void *p1, const void *p2, + size_t count) { return static_cast<int>(LIBC_SRC_STRING_MEMORY_UTILS_BCMP( reinterpret_cast<CPtr>(p1), reinterpret_cast<CPtr>(p2), count)); } diff --git a/libc/src/string/memory_utils/inline_bzero.h b/libc/src/string/memory_utils/inline_bzero.h index ed83cab..d760bac 100644 --- a/libc/src/string/memory_utils/inline_bzero.h +++ b/libc/src/string/memory_utils/inline_bzero.h @@ -16,11 +16,11 @@ namespace LIBC_NAMESPACE { -LIBC_INLINE static void inline_bzero(Ptr dst, size_t count) { +[[gnu::flatten]] LIBC_INLINE static void inline_bzero(Ptr dst, size_t count) { inline_memset(dst, 0, count); } -LIBC_INLINE static void inline_bzero(void *dst, size_t count) { +[[gnu::flatten]] LIBC_INLINE static void inline_bzero(void *dst, size_t count) { inline_bzero(reinterpret_cast<Ptr>(dst), count); } diff --git a/libc/src/string/memory_utils/inline_memcmp.h b/libc/src/string/memory_utils/inline_memcmp.h index d88d436..1fdc139 100644 --- a/libc/src/string/memory_utils/inline_memcmp.h +++ b/libc/src/string/memory_utils/inline_memcmp.h @@ -33,7 +33,8 @@ namespace LIBC_NAMESPACE { -LIBC_INLINE int inline_memcmp(const void *p1, const void *p2, size_t count) { +[[gnu::flatten]] LIBC_INLINE int inline_memcmp(const void *p1, const void *p2, + size_t count) { return static_cast<int>(LIBC_SRC_STRING_MEMORY_UTILS_MEMCMP( reinterpret_cast<CPtr>(p1), reinterpret_cast<CPtr>(p2), count)); } diff --git a/libc/src/string/memory_utils/inline_memcpy.h b/libc/src/string/memory_utils/inline_memcpy.h index a92bf4d..c88fd55e 100644 --- a/libc/src/string/memory_utils/inline_memcpy.h +++ b/libc/src/string/memory_utils/inline_memcpy.h @@ -40,8 +40,8 @@ namespace LIBC_NAMESPACE { -LIBC_INLINE void inline_memcpy(void *__restrict dst, const void *__restrict src, - size_t count) { +[[gnu::flatten]] LIBC_INLINE void +inline_memcpy(void *__restrict dst, const void *__restrict src, size_t count) { LIBC_SRC_STRING_MEMORY_UTILS_MEMCPY(reinterpret_cast<Ptr>(dst), reinterpret_cast<CPtr>(src), count); } diff --git a/libc/src/string/memory_utils/inline_memmove.h b/libc/src/string/memory_utils/inline_memmove.h index 30c2c3d..3cbc3e0 100644 --- a/libc/src/string/memory_utils/inline_memmove.h +++ b/libc/src/string/memory_utils/inline_memmove.h @@ -49,14 +49,14 @@ LIBC_INLINE constexpr bool inline_memmove_no_small_size(void *, const void *, return false; } -LIBC_INLINE bool inline_memmove_small_size(void *dst, const void *src, - size_t count) { +[[gnu::flatten]] LIBC_INLINE bool +inline_memmove_small_size(void *dst, const void *src, size_t count) { return LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_SMALL_SIZE( reinterpret_cast<Ptr>(dst), reinterpret_cast<CPtr>(src), count); } -LIBC_INLINE void inline_memmove_follow_up(void *dst, const void *src, - size_t count) { +[[gnu::flatten]] LIBC_INLINE void +inline_memmove_follow_up(void *dst, const void *src, size_t count) { LIBC_SRC_STRING_MEMORY_UTILS_MEMMOVE_FOLLOW_UP( reinterpret_cast<Ptr>(dst), reinterpret_cast<CPtr>(src), count); } |