Movatterモバイル変換
[0]ホーム
This is the mail archive of thelibc-alpha@sourceware.orgmailing list for theglibc project.
[PATCH 2/2] Call the correct memcpy function through mempcpy
- From: Siddhesh Poyarekar <siddhesh at sourceware dot org>
- To: libc-alpha at sourceware dot org
- Date: Fri, 11 Aug 2017 12:44:14 +0530
- Subject: [PATCH 2/2] Call the correct memcpy function through mempcpy
- Authentication-results: sourceware.org; auth=none
- References: <1502435654-18032-1-git-send-email-siddhesh@sourceware.org>
The generic mempcpy ends up calling only the generic memcpy and as aresult, is unable to return the most optimal results. Add ifuncresolver and entry points for mempcpy to jump into the correct memcpyimplementation for the target.* sysdeps/aarch64/multiarch/Makefile* sysdeps/aarch64/multiarch/ifunc-impl-list.c* sysdeps/aarch64/multiarch/mempcpy.c* sysdeps/aarch64/multiarch/mempcpy_chk-nonshared.S* sysdeps/aarch64/multiarch/mempcpy_chk.c* sysdeps/aarch64/multiarch/mempcpy_falkor.S* sysdeps/aarch64/multiarch/mempcpy_generic.S* sysdeps/aarch64/multiarch/mempcpy_thunderx.S--- sysdeps/aarch64/multiarch/Makefile | 5 ++- sysdeps/aarch64/multiarch/ifunc-impl-list.c | 8 ++++ sysdeps/aarch64/multiarch/mempcpy.c | 47 +++++++++++++++++++ sysdeps/aarch64/multiarch/mempcpy_chk-nonshared.S | 28 ++++++++++++ sysdeps/aarch64/multiarch/mempcpy_chk.c | 35 +++++++++++++++ sysdeps/aarch64/multiarch/mempcpy_falkor.S | 23 ++++++++++ sysdeps/aarch64/multiarch/mempcpy_generic.S | 55 +++++++++++++++++++++++ sysdeps/aarch64/multiarch/mempcpy_thunderx.S | 23 ++++++++++ 8 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 sysdeps/aarch64/multiarch/mempcpy.c create mode 100644 sysdeps/aarch64/multiarch/mempcpy_chk-nonshared.S create mode 100644 sysdeps/aarch64/multiarch/mempcpy_chk.c create mode 100644 sysdeps/aarch64/multiarch/mempcpy_falkor.S create mode 100644 sysdeps/aarch64/multiarch/mempcpy_generic.S create mode 100644 sysdeps/aarch64/multiarch/mempcpy_thunderx.Sdiff --git a/sysdeps/aarch64/multiarch/Makefile b/sysdeps/aarch64/multiarch/Makefileindex 8189eb4..5ba6962 100644--- a/sysdeps/aarch64/multiarch/Makefile+++ b/sysdeps/aarch64/multiarch/Makefile@@ -1,7 +1,8 @@ ifeq ($(subdir),string)-sysdep_routines += memcpy_generic memcpy_thunderx memcpy_falkor+sysdep_routines += memcpy_generic memcpy_thunderx memcpy_falkor \+ mempcpy_generic mempcpy_thunderx mempcpy_falkor endif ifeq ($(subdir),debug)-sysdep_routines += memcpy_chk-nonshared+sysdep_routines += memcpy_chk-nonshared mempcpy_chk-nonshared endifdiff --git a/sysdeps/aarch64/multiarch/ifunc-impl-list.c b/sysdeps/aarch64/multiarch/ifunc-impl-list.cindex d534818..fd3b305 100644--- a/sysdeps/aarch64/multiarch/ifunc-impl-list.c+++ b/sysdeps/aarch64/multiarch/ifunc-impl-list.c@@ -46,6 +46,14 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1, __memcpy_chk_thunderx) IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1, __memcpy_chk_falkor) IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1, __memcpy_chk_generic))+ IFUNC_IMPL (i, name, mempcpy,+ IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_thunderx)+ IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_falkor)+ IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_generic))+ IFUNC_IMPL (i, name, __mempcpy_chk,+ IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1, __mempcpy_chk_thunderx)+ IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1, __mempcpy_chk_falkor)+ IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1, __mempcpy_chk_generic)) IFUNC_IMPL (i, name, memmove, IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_thunderx) IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_generic))diff --git a/sysdeps/aarch64/multiarch/mempcpy.c b/sysdeps/aarch64/multiarch/mempcpy.cnew file mode 100644index 0000000..3492f59--- /dev/null+++ b/sysdeps/aarch64/multiarch/mempcpy.c@@ -0,0 +1,47 @@+/* Multiple versions of mempcpy. AARCH64 version.+ Copyright (C) 2017 Free Software Foundation, Inc.+ This file is part of the GNU C Library.++ The GNU C Library is free software; you can redistribute it and/or+ modify it under the terms of the GNU Lesser General Public+ License as published by the Free Software Foundation; either+ version 2.1 of the License, or (at your option) any later version.++ The GNU C Library is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ Lesser General Public License for more details.++ You should have received a copy of the GNU Lesser General Public+ License along with the GNU C Library; if not, see+ <http://www.gnu.org/licenses/>. */++/* Define multiple versions only for the definition in libc. */++#if IS_IN (libc)+/* Redefine mempcpy so that the compiler won't complain about the type+ mismatch with the IFUNC selector in strong_alias, below. */+# undef mempcpy+# undef __mempcpy+# define mempcpy __redirect_mempcpy+# include <string.h>+# include <init-arch.h>++extern __typeof (__redirect_mempcpy) __mempcpy;++extern __typeof (__redirect_mempcpy) __mempcpy_generic attribute_hidden;+extern __typeof (__redirect_mempcpy) __mempcpy_thunderx attribute_hidden;+extern __typeof (__redirect_mempcpy) __mempcpy_falkor attribute_hidden;++libc_ifunc (__mempcpy,+ (IS_THUNDERX (midr)+ ? __mempcpy_thunderx+ : (IS_FALKOR (midr)+? __mempcpy_falkor+: __mempcpy_generic)));++# undef mempcpy+strong_alias (__mempcpy, mempcpy);+#else+# include <string/mempcpy.c>+#endifdiff --git a/sysdeps/aarch64/multiarch/mempcpy_chk-nonshared.S b/sysdeps/aarch64/multiarch/mempcpy_chk-nonshared.Snew file mode 100644index 0000000..5a6afdb--- /dev/null+++ b/sysdeps/aarch64/multiarch/mempcpy_chk-nonshared.S@@ -0,0 +1,28 @@+/* Non-shared version of mempcpy_chk.+ Copyright (C) 2017 Free Software Foundation, Inc.+ This file is part of the GNU C Library.++ The GNU C Library is free software; you can redistribute it and/or+ modify it under the terms of the GNU Lesser General Public+ License as published by the Free Software Foundation; either+ version 2.1 of the License, or (at your option) any later version.++ The GNU C Library is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ Lesser General Public License for more details.++ You should have received a copy of the GNU Lesser General Public+ License along with the GNU C Library; if not, see+ <http://www.gnu.org/licenses/>. */++#include <sysdep.h>++#if IS_IN (libc) && !defined SHARED+ENTRY_ALIGN (__mempcpy_chk, 6)+cmpx3, x2+b.lo__chk_fail+bmempcpy+nop+END (__mempcpy_chk)+#endifdiff --git a/sysdeps/aarch64/multiarch/mempcpy_chk.c b/sysdeps/aarch64/multiarch/mempcpy_chk.cnew file mode 100644index 0000000..1b4bf15--- /dev/null+++ b/sysdeps/aarch64/multiarch/mempcpy_chk.c@@ -0,0 +1,35 @@+/* Multiple versions of mempcpy. AARCH64 version.+ Copyright (C) 2017 Free Software Foundation, Inc.+ This file is part of the GNU C Library.++ The GNU C Library is free software; you can redistribute it and/or+ modify it under the terms of the GNU Lesser General Public+ License as published by the Free Software Foundation; either+ version 2.1 of the License, or (at your option) any later version.++ The GNU C Library is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ Lesser General Public License for more details.++ You should have received a copy of the GNU Lesser General Public+ License along with the GNU C Library; if not, see+ <http://www.gnu.org/licenses/>. */++/* Define multiple versions only for the definition in libc. */++#if IS_IN (libc) && defined SHARED+# include <string.h>+# include <init-arch.h>++extern __typeof (__mempcpy_chk) __mempcpy_chk_generic attribute_hidden;+extern __typeof (__mempcpy_chk) __mempcpy_chk_thunderx attribute_hidden;+extern __typeof (__mempcpy_chk) __mempcpy_chk_falkor attribute_hidden;++libc_ifunc (__mempcpy_chk,+ (IS_THUNDERX (midr)+ ? __mempcpy_chk_thunderx+ : (IS_FALKOR (midr)+? __mempcpy_chk_falkor+: __mempcpy_chk_generic)));+#endifdiff --git a/sysdeps/aarch64/multiarch/mempcpy_falkor.S b/sysdeps/aarch64/multiarch/mempcpy_falkor.Snew file mode 100644index 0000000..4cf822d--- /dev/null+++ b/sysdeps/aarch64/multiarch/mempcpy_falkor.S@@ -0,0 +1,23 @@+/* Optimized mempcpy for Qualcomm Falkor processor.+ Copyright (C) 2017 Free Software Foundation, Inc.++ This file is part of the GNU C Library.++ The GNU C Library is free software; you can redistribute it and/or+ modify it under the terms of the GNU Lesser General Public+ License as published by the Free Software Foundation; either+ version 2.1 of the License, or (at your option) any later version.++ The GNU C Library is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ Lesser General Public License for more details.++ You should have received a copy of the GNU Lesser General Public+ License along with the GNU C Library. If not, see+ <http://www.gnu.org/licenses/>. */++#define MEMPCPY __mempcpy_falkor+# define MEMPCPY_CHK __mempcpy_chk_falkor+#define MEMCPY __memcpy_falkor+#include <sysdeps/aarch64/multiarch/mempcpy_generic.S>diff --git a/sysdeps/aarch64/multiarch/mempcpy_generic.S b/sysdeps/aarch64/multiarch/mempcpy_generic.Snew file mode 100644index 0000000..2f4e8ad--- /dev/null+++ b/sysdeps/aarch64/multiarch/mempcpy_generic.S@@ -0,0 +1,55 @@+/* Generic mempcpy to select via IFUNC.+ Copyright (C) 2017 Free Software Foundation, Inc.++ This file is part of the GNU C Library.++ The GNU C Library is free software; you can redistribute it and/or+ modify it under the terms of the GNU Lesser General Public+ License as published by the Free Software Foundation; either+ version 2.1 of the License, or (at your option) any later version.++ The GNU C Library is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ Lesser General Public License for more details.++ You should have received a copy of the GNU Lesser General Public+ License along with the GNU C Library. If not, see+ <http://www.gnu.org/licenses/>. */++#include <sysdep.h>++#if IS_IN (libc) && !defined MEMPCPY+# define MEMPCPY __mempcpy_generic+# define MEMPCPY_CHK __mempcpy_chk_generic+# define MEMCPY __memcpy_generic++# undef libc_hidden_builtin_def+# define libc_hidden_builtin_def(name)++# ifdef SHARED+ .globl __GI_mempcpy; __GI_mempcpy = __mempcpy_generic+# endif++#endif++/* Push the sum of the destination and count on to stack and return it after+ memcpy is done. We could avoid the register spill by ensuring that the+ memcpy does not use one of the scratch registers, but that could get+ increasingly error-prone when we add new implementations for memcpy. */++#ifdef SHARED+ENTRY_ALIGN (MEMPCPY_CHK, 4)+cmpx3, x2+b.lo__chk_fail+END (MEMPCPY_CHK)+#endif++ENTRY_ALIGN (MEMPCPY, 4)+addx15, x0, x2+stpx15, x30, [sp, -16]+blMEMCPY+ldpx0, x30, [sp, -16]+ret+END (MEMPCPY)+libc_hidden_builtin_def (MEMPCPY)diff --git a/sysdeps/aarch64/multiarch/mempcpy_thunderx.S b/sysdeps/aarch64/multiarch/mempcpy_thunderx.Snew file mode 100644index 0000000..41f1b2f--- /dev/null+++ b/sysdeps/aarch64/multiarch/mempcpy_thunderx.S@@ -0,0 +1,23 @@+/* A Thunderx Optimized mempcpy implementation for AARCH64.+ Copyright (C) 2017 Free Software Foundation, Inc.++ This file is part of the GNU C Library.++ The GNU C Library is free software; you can redistribute it and/or+ modify it under the terms of the GNU Lesser General Public+ License as published by the Free Software Foundation; either+ version 2.1 of the License, or (at your option) any later version.++ The GNU C Library is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU+ Lesser General Public License for more details.++ You should have received a copy of the GNU Lesser General Public+ License along with the GNU C Library. If not, see+ <http://www.gnu.org/licenses/>. */++#define MEMPCPY __mempcpy_thunderx+# define MEMPCPY_CHK __mempcpy_chk_thunderx+#define MEMCPY __memcpy_thunderx+#include <sysdeps/aarch64/multiarch/mempcpy_generic.S>-- 2.7.4
[8]ページ先頭