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.
This commit is contained in:
Adhemerval Zanella 2014-05-02 12:00:36 -05:00
parent 7776e6692f
commit 19c4bec0f4
8 changed files with 64 additions and 26 deletions

View File

@ -1,3 +1,18 @@
2014-05-04 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* 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 <adconrad@0c3.net>
* locale/iso-4217.def: Reintroduce XDR currency.

View File

@ -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;

View File

@ -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 <sysdeps/powerpc/powerpc64/memcpy.S>

View File

@ -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 <string.h>
# include <shlib-compat.h>
# 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

View File

@ -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. */

View File

@ -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 <string.h>
# include <shlib-compat.h>
# 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

View File

@ -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 <sysdeps/powerpc/powerpc64/strlen.S>

View File

@ -17,15 +17,25 @@
<http://www.gnu.org/licenses/>. */
#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 <string.h>
# include <shlib-compat.h>
# 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