aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSriraman Tallam <tmsriram@google.com>2015-07-27 10:14:19 -0700
committerSriraman Tallam <tmsriram@google.com>2015-07-27 10:14:19 -0700
commit3532d2e2bcbe2f7f2bb63fe4633f67acf1c11ed6 (patch)
tree20f962217271a802d8de48673805d3f29b8bf4ec
parentd1c2791a63fb9a8a595bc13362ed465439322c99 (diff)
downloadglibc-3532d2e2bcbe2f7f2bb63fe4633f67acf1c11ed6.zip
glibc-3532d2e2bcbe2f7f2bb63fe4633f67acf1c11ed6.tar.gz
glibc-3532d2e2bcbe2f7f2bb63fe4633f67acf1c11ed6.tar.bz2
Redeclare hot external libc functions with new GCC function attribute "noplt" to allow calls to these functions to avoid the PLT. This change improves
-rw-r--r--README.google9
-rw-r--r--math/bits/mathcalls.h1
-rw-r--r--misc/sys/cdefs.h9
-rw-r--r--string/string.h25
4 files changed, 34 insertions, 10 deletions
diff --git a/README.google b/README.google
index 2c776b0..9c43bde 100644
--- a/README.google
+++ b/README.google
@@ -443,3 +443,12 @@ libio/fmemopen.c
libio/test-fmemopen.c
For b/22167761, backport fix buffer overflow for writes to memory buffer stream (PR18549)
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7c2ce714d4e853aadbec13b920576fdfada520f1
+
+string/string.h
+math/bits/mathcalls.h
+misc/sys/cdefs.h
+ Re-declare hot libc functions with "noplt" attribute available GCC 4.9
+ onwards. This attribute allows calls to these functions to avoid the
+ PLT and improves the performance of some of our code via better icache
+ and iTLB performance.
+ (tmsriram, google-local)
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index 4cb39e8..6ff3f69 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -150,6 +150,7 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Return X to the Y power. */
+__attribute_noplt__
__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
/* Return the square root of X. */
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index c867be7..e275a68 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -232,6 +232,15 @@
# define __attribute_pure__ /* Ignore */
#endif
+/* GCC 4.9 onwards supports function attribute "noplt". Calls to functions
+ declared with this attribute avoid the PLT and call them indirectly via
+ a GOT entry. */
+#if __GNUC_PREREQ (4,9) && defined(__GOOGLE_GLIBC_NOPLT)
+# define __attribute_noplt__ __attribute__ ((noplt))
+#else
+# define __attribute_noplt__ /* Ignore */
+#endif
+
/* This declaration tells the compiler that the value is constant. */
#if __GNUC_PREREQ (2,5)
# define __attribute_const__ __attribute__ ((__const__))
diff --git a/string/string.h b/string/string.h
index b127e8d..0981f89 100644
--- a/string/string.h
+++ b/string/string.h
@@ -44,11 +44,13 @@ __BEGIN_DECLS
__BEGIN_NAMESPACE_STD
/* Copy N bytes of SRC to DEST. */
extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
- size_t __n) __THROW __nonnull ((1, 2));
+ size_t __n)
+ __THROW __attribute_noplt__ __nonnull ((1, 2));
+
/* Copy N bytes of SRC to DEST, guaranteeing
correct behavior for overlapping strings. */
extern void *memmove (void *__dest, const void *__src, size_t __n)
- __THROW __nonnull ((1, 2));
+ __THROW __attribute_noplt__ __nonnull ((1, 2));
__END_NAMESPACE_STD
/* Copy no more than N bytes of SRC to DEST, stopping when C is found.
@@ -63,20 +65,23 @@ extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
__BEGIN_NAMESPACE_STD
/* Set N bytes of S to C. */
-extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
+extern void *memset (void *__s, int __c, size_t __n)
+ __THROW __attribute_noplt__ __nonnull ((1));
/* Compare N bytes of S1 and S2. */
extern int memcmp (const void *__s1, const void *__s2, size_t __n)
- __THROW __attribute_pure__ __nonnull ((1, 2));
+ __THROW __attribute_pure__ __attribute_noplt__ __nonnull ((1, 2));
/* Search N bytes of S for C. */
#ifdef __CORRECT_ISO_CPP_STRING_H_PROTO
extern "C++"
{
extern void *memchr (void *__s, int __c, size_t __n)
- __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
+ __THROW __asm ("memchr") __attribute_pure__
+ __attribute_noplt__ __nonnull ((1));
extern const void *memchr (const void *__s, int __c, size_t __n)
- __THROW __asm ("memchr") __attribute_pure__ __nonnull ((1));
+ __THROW __asm ("memchr") __attribute_pure__
+ __attribute_noplt__ __nonnull ((1));
# ifdef __OPTIMIZE__
__extern_always_inline void *
@@ -94,7 +99,7 @@ memchr (const void *__s, int __c, size_t __n) __THROW
}
#else
extern void *memchr (const void *__s, int __c, size_t __n)
- __THROW __attribute_pure__ __nonnull ((1));
+ __THROW __attribute_pure__ __attribute_noplt__ __nonnull ((1));
#endif
__END_NAMESPACE_STD
@@ -142,10 +147,10 @@ extern char *strncat (char *__restrict __dest, const char *__restrict __src,
/* Compare S1 and S2. */
extern int strcmp (const char *__s1, const char *__s2)
- __THROW __attribute_pure__ __nonnull ((1, 2));
+ __THROW __attribute_pure__ __attribute_noplt__ __nonnull ((1, 2));
/* Compare N characters of S1 and S2. */
extern int strncmp (const char *__s1, const char *__s2, size_t __n)
- __THROW __attribute_pure__ __nonnull ((1, 2));
+ __THROW __attribute_pure__ __attribute_noplt__ __nonnull ((1, 2));
/* Compare the collated forms of S1 and S2. */
extern int strcoll (const char *__s1, const char *__s2)
@@ -397,7 +402,7 @@ extern void *mempcpy (void *__restrict __dest,
__BEGIN_NAMESPACE_STD
/* Return the length of S. */
extern size_t strlen (const char *__s)
- __THROW __attribute_pure__ __nonnull ((1));
+ __THROW __attribute_pure__ __attribute_noplt__ __nonnull ((1));
__END_NAMESPACE_STD
#ifdef __USE_XOPEN2K8