From 19c4bec0f43599eecc2f32de96ae179cd7d64053 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 2 May 2014 12:00:36 -0500 Subject: [PATCH] PowerPC: ifunc improvement for internal calls This patch changes de default symbol redirection for internal call of memcpy, memset, memchr, and strlen to the IFUNC resolved ones. The performance improvement is noticeable in algorithms that uses these symbols extensible, like the regex functions. --- ChangeLog | 15 ++++++++++++ .../powerpc32/power4/multiarch/memchr-ppc32.c | 3 +-- sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S | 3 +-- sysdeps/powerpc/powerpc64/multiarch/memcpy.c | 27 ++++++++++++++-------- sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S | 3 +-- sysdeps/powerpc/powerpc64/multiarch/memset.c | 20 ++++++++++++---- sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S | 3 +-- sysdeps/powerpc/powerpc64/multiarch/strlen.c | 16 ++++++++++--- 8 files changed, 64 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac0d69e..ad0484b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2014-05-04 Adhemerval Zanella + + * sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c + [libc_hidden_builtin_def]: Define to empty value. + * sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S: + [libc_hidden_builtin_def]: Likewise. + * sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S: + [libc_hidden_builtin_def]: Likewise. + * sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S: + [libc_hidden_builtin_def]: Likewise. + * sysdeps/powerpc/powerpc64/multiarch/memcpy.c (memcpy): Redefined to + __redirect_memcpy and define ifunc as default hidden symbol. + * sysdeps/powerpc/powerpc64/multiarch/memset.c (memset): Likewise. + * sysdeps/powerpc/powerpc64/multiarch/strlen.c (strlen): Likewise. + 2014-05-04 Adam Conrad * locale/iso-4217.def: Reintroduce XDR currency. diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c index 43c5652..4bd6bb9 100644 --- a/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c +++ b/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c @@ -25,8 +25,7 @@ #ifdef SHARED # undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ - __hidden_ver1 (__memchr_ppc, __GI_memchr, __memchr_ppc); +# define libc_hidden_builtin_def(name) #endif extern __typeof (memchr) __memchr_ppc attribute_hidden; diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S b/sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S index a09d760..c630654 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S +++ b/sysdeps/powerpc/powerpc64/multiarch/memcpy-ppc64.S @@ -36,8 +36,7 @@ END_2(__memcpy_ppc) # undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ - .globl __GI_memcpy; __GI_memcpy = __memcpy_ppc +# define libc_hidden_builtin_def(name) #endif #include diff --git a/sysdeps/powerpc/powerpc64/multiarch/memcpy.c b/sysdeps/powerpc/powerpc64/multiarch/memcpy.c index 6a91630..305e963 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/memcpy.c +++ b/sysdeps/powerpc/powerpc64/multiarch/memcpy.c @@ -20,20 +20,23 @@ DSO. In static binaries we need memcpy before the initialization happened. */ #if defined SHARED && !defined NOT_IN_libc +/* Redefine memcpy so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias, below. */ +# undef memcpy +# define memcpy __redirect_memcpy # include -# include # include "init-arch.h" -extern __typeof (memcpy) __memcpy_ppc attribute_hidden; -extern __typeof (memcpy) __memcpy_power4 attribute_hidden; -extern __typeof (memcpy) __memcpy_cell attribute_hidden; -extern __typeof (memcpy) __memcpy_power6 attribute_hidden; -extern __typeof (memcpy) __memcpy_a2 attribute_hidden; -extern __typeof (memcpy) __memcpy_power7 attribute_hidden; +extern __typeof (__redirect_memcpy) __libc_memcpy; -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle - ifunc symbol properly. */ -libc_ifunc (memcpy, +extern __typeof (__redirect_memcpy) __memcpy_ppc attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_power4 attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_cell attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_power6 attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_a2 attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_power7 attribute_hidden; + +libc_ifunc (__libc_memcpy, (hwcap & PPC_FEATURE_HAS_VSX) ? __memcpy_power7 : (hwcap & PPC_FEATURE_ARCH_2_06) @@ -45,4 +48,8 @@ libc_ifunc (memcpy, (hwcap & PPC_FEATURE_POWER4) ? __memcpy_power4 : __memcpy_ppc); + +#undef memcpy +strong_alias (__libc_memcpy, memcpy); +libc_hidden_ver (__libc_memcpy, memcpy); #endif diff --git a/sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S b/sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S index 65b3afe..3601a77 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S +++ b/sysdeps/powerpc/powerpc64/multiarch/memset-ppc64.S @@ -47,8 +47,7 @@ END_GEN_TB (__bzero_ppc,TB_TOCLESS) END_2(__memset_ppc) # undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ - .globl __GI_memset; __GI_memset = __memset_ppc +# define libc_hidden_builtin_def(name) #endif /* Do not implement __bzero at powerpc64/memset.S. */ diff --git a/sysdeps/powerpc/powerpc64/multiarch/memset.c b/sysdeps/powerpc/powerpc64/multiarch/memset.c index 829d127..aa2ae70 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/memset.c +++ b/sysdeps/powerpc/powerpc64/multiarch/memset.c @@ -18,18 +18,24 @@ /* Define multiple versions only for definition in libc. */ #if defined SHARED && !defined NOT_IN_libc +/* Redefine memset so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias, below. */ +# undef memset +# define memset __redirect_memset # include # include # include "init-arch.h" -extern __typeof (memset) __memset_ppc attribute_hidden; -extern __typeof (memset) __memset_power4 attribute_hidden; -extern __typeof (memset) __memset_power6 attribute_hidden; -extern __typeof (memset) __memset_power7 attribute_hidden; +extern __typeof (__redirect_memset) __libc_memset; + +extern __typeof (__redirect_memset) __memset_ppc attribute_hidden; +extern __typeof (__redirect_memset) __memset_power4 attribute_hidden; +extern __typeof (__redirect_memset) __memset_power6 attribute_hidden; +extern __typeof (__redirect_memset) __memset_power7 attribute_hidden; /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle ifunc symbol properly. */ -libc_ifunc (memset, +libc_ifunc (__libc_memset, (hwcap & PPC_FEATURE_HAS_VSX) ? __memset_power7 : (hwcap & PPC_FEATURE_ARCH_2_05) @@ -37,4 +43,8 @@ libc_ifunc (memset, (hwcap & PPC_FEATURE_POWER4) ? __memset_power4 : __memset_ppc); + +#undef memset +strong_alias (__libc_memset, memset); +libc_hidden_ver (__libc_memset, memset); #endif diff --git a/sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S b/sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S index efcc212..a195e9a 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S +++ b/sysdeps/powerpc/powerpc64/multiarch/strlen-ppc64.S @@ -35,8 +35,7 @@ END_2(__strlen_ppc) # undef libc_hidden_builtin_def -# define libc_hidden_builtin_def(name) \ - .globl __GI_strlen; __GI_strlen = __strlen_ppc +# define libc_hidden_builtin_def(name) #endif #include diff --git a/sysdeps/powerpc/powerpc64/multiarch/strlen.c b/sysdeps/powerpc/powerpc64/multiarch/strlen.c index 6574696..d2c26e9 100644 --- a/sysdeps/powerpc/powerpc64/multiarch/strlen.c +++ b/sysdeps/powerpc/powerpc64/multiarch/strlen.c @@ -17,15 +17,25 @@ . */ #if defined SHARED && !defined NOT_IN_libc +/* Redefine strlen so that the compiler won't complain about the type + mismatch with the IFUNC selector in strong_alias, below. */ +# undef strlen +# define strlen __redirect_strlen # include # include # include "init-arch.h" -extern __typeof (strlen) __strlen_ppc attribute_hidden; -extern __typeof (strlen) __strlen_power7 attribute_hidden; +extern __typeof (__redirect_strlen) __libc_strlen; -libc_ifunc (strlen, +extern __typeof (__redirect_strlen) __strlen_ppc attribute_hidden; +extern __typeof (__redirect_strlen) __strlen_power7 attribute_hidden; + +libc_ifunc (__libc_strlen, (hwcap & PPC_FEATURE_HAS_VSX) ? __strlen_power7 : __strlen_ppc); + +#undef strlen +strong_alias (__libc_strlen, strlen) +libc_hidden_ver (__libc_strlen, strlen) #endif -- 2.7.4