This is an archive of the discontinued LLVM Phabricator instance.

[libc] Extract out an architecture independent copy of memcpy implementation.
ClosedPublic

Authored by sivachandra on Jun 10 2020, 4:40 PM.

Diff Detail

Event Timeline

sivachandra created this revision.Jun 10 2020, 4:40 PM

I am trying to get the string functions work on aarch64. While memset and bzero work as is, memcpy does not because of the x86 specific arrangement we have currently. The x86 specific pieces are actually in dead code. So I went ahead and removed them in this patch. If required in future, we should add it back in a fashion which does not break the build for non-x86 architectures.

Also, I do not remember everything we discussed in the past. So, feel free to tell me I am doing rubbish.

This comment was removed by gchatelet.

I am trying to get the string functions work on aarch64. While memset and bzero work as is, memcpy does not because of the x86 specific arrangement we have currently. The x86 specific pieces are actually in dead code. So I went ahead and removed them in this patch. If required in future, we should add it back in a fashion which does not break the build for non-x86 architectures.

memset and bzero are generic and can be used as-is for all architectures.
They may need to be tweaked for individual architecture later on but the current code is good enough.

memcpyis a different story. The C++ implementation is quite tied to x86 so I would rather duplicate the code.
Keep the one we have with the reference to AVX and repmovsb for x86 (libc/src/string/x86/memcpy.cpp)
Duplicate it without AVX / Repmovsb for a generic implementation (libc/src/string/memcpy.cpp)
It also sets an example for anyone wanting to provide an architecture specific implementation.

Thx for the -O2 flag!

Make an architecture independent copy of memcpy implementation as suggested.

I am trying to get the string functions work on aarch64. While memset and bzero work as is, memcpy does not because of the x86 specific arrangement we have currently. The x86 specific pieces are actually in dead code. So I went ahead and removed them in this patch. If required in future, we should add it back in a fashion which does not break the build for non-x86 architectures.

memset and bzero are generic and can be used as-is for all architectures.
They may need to be tweaked for individual architecture later on but the current code is good enough.

memcpyis a different story. The C++ implementation is quite tied to x86 so I would rather duplicate the code.
Keep the one we have with the reference to AVX and repmovsb for x86 (libc/src/string/x86/memcpy.cpp)
Duplicate it without AVX / Repmovsb for a generic implementation (libc/src/string/memcpy.cpp)
It also sets an example for anyone wanting to provide an architecture specific implementation.

Thx for the -O2 flag!

OK. I have updated as you suggest.

I am trying to get the string functions work on aarch64. While memset and bzero work as is, memcpy does not because of the x86 specific arrangement we have currently. The x86 specific pieces are actually in dead code. So I went ahead and removed them in this patch. If required in future, we should add it back in a fashion which does not break the build for non-x86 architectures.

memset and bzero are generic and can be used as-is for all architectures.
They may need to be tweaked for individual architecture later on but the current code is good enough.

memcpyis a different story. The C++ implementation is quite tied to x86 so I would rather duplicate the code.
Keep the one we have with the reference to AVX and repmovsb for x86 (libc/src/string/x86/memcpy.cpp)
Duplicate it without AVX / Repmovsb for a generic implementation (libc/src/string/memcpy.cpp)
It also sets an example for anyone wanting to provide an architecture specific implementation.

Thx for the -O2 flag!

OK. I have updated as you suggest.

I will update the description after hearing back from @gchatelet.

gchatelet accepted this revision.Jun 15 2020, 8:21 AM

Perfect! Thx!

This revision is now accepted and ready to land.Jun 15 2020, 8:21 AM
sivachandra retitled this revision from [libc] Remove dead code from memcpy to make it machine independent. to [libc] Extract out an architecture independent copy of memcpy implementation..Jun 15 2020, 9:18 AM
sivachandra edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.