How does clang pick the memcpy optimized for the floating point co-processor on my ARM target?

I am working on project that is currently build with gcc and run-times based on newlib 4.3.0.

As an experiment to see if we can reduce link time I am trying out a clang compile linked with lld thin lto. So far so good link time is reduced but run-time performance of my target has become worse with clang.
Clang run-times same as gcc are also based on newlib 4.3.0.

By debugging and comparing my gcc builds with my clang builds I have observed that my clang builds, pick the “wrong” memcpy i.e. clang picks the function named libc_a-aeabi_memcpy-armv7a.o whereas gcc picks the function named libc_a-memcpy-armv7a.o. Via llvm-objdump I can see that libc.a contains both implementations.

aeabi_memcpy-armv7a, seems to be a version of memcpy optimized for arm with hard floating point support. As such one should think this is the right pick but it is actually slower than the one that gcc picks since it does not use the the vectorization instructions that the arm hard floating point unit/ co-processor allows for?

When I compile for both gcc and clang I use the options -mthumb -mfloat-abi=hard -mcpu=cortex-a9 -mfpu=neon -munaligned-access.
I.e. basically I am telling the cpu and fpu I have which should then make clang pick the right optimized version of memcpy in newlib. Except it picks the wrong one?

Shouldn’t setting up the cpu and fpu be enough to tell clang that is can pick the “right” memcpy?
Where the “right” memcpy is the one that actually uses the hard floating point unit my cortex-a9 actually has, same as gcc does.

Anyways somehow clang does not pick the “right” memcpy, my question therefore pertains what am I doing that makes clang choose the “wrong” aeabi_memcpy? How clang picks it I have not been able to figure out since libc.a contains both implementations it must pick it somehow and map it to the user, but how eludes me.

Here are some details on the placement of the memcpy functions that come into place in above:
libc (newlib 4.3.0)

newlib-cygwinnewliblibcmachinearmmemcpy-armv7a.S
Uses vectorization i.e. hard floating point co-processor.
This is the “right” faster one pick by gcc in my gcc builds.
newlib-cygwinnewliblibcmachinearmaeabi_memcpy-armv7a.S
Does NOT use vectorization
This is the “wrong” slower one picked by clang in my clang builds.
Hope someone can help me figure out what I am doing wrong or shine some light one where clang picks the right version of the memcpy for the processor setup in question

newlib-cygwinnewliblibcmachinearmmemcpy-armv7a.S is the one that includes the “right” memcpy-armv7a.S. Below I have included memcpy-armv7a.S.
To debug if the macroes __ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == ‘A’ && defined(__ARM_FEATURE_UNALIGNED) are true, I have tried to introduce a compile error. This checks out which also aligns with the llvm-objdump of libc.a that contains both implementations.

#include “arm-acle-compat.h”

#if defined (OPTIMIZE_SIZE) || defined (PREFER_SIZE_OVER_SPEED)
/* Defined in memcpy-stub.c. */

#elif (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == ‘A’
&& defined (__ARM_FEATURE_UNALIGNED))
todo_memcpy_armv7a_was_included //temp compile error to determine if above are defined
#include “memcpy-armv7a.S”

#elif __ARM_ARCH_ISA_THUMB == 2 && !__ARM_ARCH_ISA_ARM
#include “memcpy-armv7m.S”

#else
/* Defined in memcpy-stub.c. */

#endif

Since llvm-objdump of libc.a contains both implementations it must be clang that somehow creates the right alias for mempcy, I just havn’t been able figure out if this is right or where it specifically does it.

I have also generated a map file the project I am compiling, the map file shows that aeabi_memcpy-armv7a.S is used, I expected it to be memcpy-armv7m.S:
1156bc 1156bc 208 4 C:toolsllvm-project18.1.3.B1.03062024bin..libclang-runtimes/arm-none-eabi/armv7a_thumb_hard_neon_exn_rttiliblibc.a(libc_a-aeabi_memcpy-armv7a.o):(.text)
1156bc 1156bc 0 1 $a.0
1156bc 1156bc 0 1 __aeabi_memcpy
1156dc 1156dc 0 1 word_aligned
1156fc 1156fc 0 1 two_word_aligned
11574c 11574c 0 1 copy_less_than_64
115764 115764 0 1 copy_less_than_8
11577c 11577c 0 1 copy_less_than_4
1157a0 1157a0 0 1 return
1157a8 1157a8 0 1 dst_not_word_aligned
1157d8 1157d8 0 1 src_not_word_aligned
11588c 11588c 0 1 __aeabi_memcpy4
1158a0 1158a0 0 1 __aeabi_memcpy8

New contributor

Klaus Petersen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật