This is an archive of the discontinued LLVM Phabricator instance.

[libc] Switch to new implementation of mem* functions
ClosedPublic

Authored by gchatelet on Oct 24 2022, 6:41 AM.

Details

Summary

The new framework makes it explicit which processor feature is being
used and allows for easier per platform customization:

  • ARM cpu now uses trivial implementations to reduce code size.
  • Memcmp, Bcmp and Memmove have been optimized for x86
  • Bcmp has been optimized for aarch64.

This is a reland of https://reviews.llvm.org/D135134 (b3f1d58)

Diff Detail

Event Timeline

gchatelet created this revision.Oct 24 2022, 6:41 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 24 2022, 6:41 AM
gchatelet requested review of this revision.Oct 24 2022, 6:41 AM
courbet added inline comments.Oct 24 2022, 8:04 AM
libc/src/string/memory_utils/memcpy_implementations.h
127

why is ARM always embedded_tiny ? Shouldn't that be orthogonal ? I could imagine some tiny aarch64 processors...

libc/src/string/memory_utils/memset_implementations.h
108

ditto

gchatelet added inline comments.Oct 24 2022, 8:39 AM
libc/src/string/memory_utils/memcpy_implementations.h
127

Fair enough, for now this is not customizable but it is expected to be in the future.

There has been some discussions on discourse but we need to better define what would be a reasonable default implementation.

Also it is unclear whether we want to customize per function or for the library as a whole

I will hold this patch until I'm clear whether this will impact our users or not.

gchatelet added inline comments.
libc/src/string/memory_utils/memcpy_implementations.h
127

@sivachandra confirmed that ARM support is minimal for now and that we don't have active users . aarch64 is solely targeted at ARM servers. Of course this can change but I think the patch is safe to land as it is now. Let's refine the needs and iterate in subsequent patches.

courbet accepted this revision.Oct 25 2022, 12:22 AM
This revision is now accepted and ready to land.Oct 25 2022, 12:22 AM
This revision was automatically updated to reflect the committed changes.
gchatelet reopened this revision.Oct 27 2022, 1:03 PM
This revision is now accepted and ready to land.Oct 27 2022, 1:03 PM
gchatelet requested review of this revision.Oct 27 2022, 1:12 PM

@courbet use this link to check the diff with the previously submitted patch.
Also let's wait for D136865 to be in before submitting this one.

courbet added inline comments.Oct 28 2022, 12:56 AM
libc/src/string/memory_utils/memcmp_implementations.h
97

This is unfortunate :(

This should be caught by unit tests, can you add one ?

gchatelet marked 3 inline comments as done.Oct 31 2022, 2:16 PM
gchatelet added inline comments.
libc/src/string/memory_utils/memcmp_implementations.h
97

Yep this was done in D136865

gchatelet marked an inline comment as done.Nov 2 2022, 2:09 AM

I'm submitting this patch once again. 🤞

This revision was not accepted when it landed; it landed in state Needs Review.Nov 2 2022, 2:10 AM
This revision was automatically updated to reflect the committed changes.