[libc-commits] [libc] [libc] Remove unnecessary call in memfunction dispatchers (PR #75800)

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Tue Dec 19 02:12:46 PST 2023


================
@@ -32,7 +32,8 @@
 
 namespace LIBC_NAMESPACE {
 
-LIBC_INLINE int inline_bcmp(const void *p1, const void *p2, size_t count) {
+__attribute__((flatten)) LIBC_INLINE int
----------------
gchatelet wrote:

> inline_memcmp_x86 called from multiple places and compiler decides to reduce code size

`inline_memcmp` is called from within libc but it's also exposed as `memcmp`, that may be the reason.
Another reason (maybe?) is that `memcmp` is exported as a weak symbol so that the user can override it with another implementation if needed.

> The question is: can compiler tomorrow inline inline_memcmp_x86 into inline_memcmp (as we asked with flatten), but make memcmp jmp to inline_memcmp?
This is entirely possible, we should probably also mark them with `flatten` when they are trivial.

> Another good question is how to test this. These things regress due to compiler bugs, or seemingly unrelated refactorings. Quality bugs are more frequent than crashing bugs because they are silent and go unnoticed.

@nickdesaulniers for visibility.
Good question indeed. This could be part of the integration tests. We'd have to disassemble the function and make sure they do not consist in a single jump to another function.

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


More information about the libc-commits mailing list