public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-06-03 14:08 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-06-03 14:08 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=83cdf9c6c0a4026356f1174ebc18cbd814d86e53

commit 83cdf9c6c0a4026356f1174ebc18cbd814d86e53
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 35a54b694a..536b825a03 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2024-04-17 20:09 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:09 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=96f8c9eefa06c2795aa3cfc689bfe801116d6221

commit 96f8c9eefa06c2795aa3cfc689bfe801116d6221
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-hash-funcs-kernel.h                 |  4 ++--
 benchtests/bench-hash-funcs.c                        |  2 +-
 benchtests/bench-strchr.c                            |  4 ++--
 debug/tst-backtrace.h                                |  2 +-
 debug/tst-ssp-1.c                                    |  2 +-
 elf/tst-p_alignmod-base.c                            |  2 +-
 gmon/tst-gmon.c                                      |  8 +++++---
 gmon/tst-mcount-overflow.c                           | 10 ++++++----
 malloc/tst-malloc-thread-exit.c                      |  2 +-
 malloc/tst-malloc-thread-fail.c                      |  2 +-
 malloc/tst-mallocstate.c                             |  2 +-
 misc/sys/cdefs.h                                     |  7 +++++++
 misc/tst-syscalls.c                                  | 14 +++++++-------
 nptl/tst-minstack-throw.cc                           |  8 ++++----
 nptl/tst-thread-exit-clobber.cc                      | 12 ++++++------
 nptl/tst-thread_local1.cc                            | 12 ++++++------
 stdlib/tst-makecontext-align.c                       | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                             |  2 +-
 stdlib/tst-setcontext10.c                            |  6 +++---
 stdlib/tst-setcontext11.c                            |  2 +-
 stdlib/tst-setcontext5.c                             |  4 ++--
 stdlib/tst-setcontext8.c                             |  2 +-
 stdlib/tst-setcontext9.c                             |  2 +-
 stdlib/tst-swapcontext1.c                            |  8 ++++----
 stdlib/tst-swapcontext2.c                            |  8 ++++----
 stdlib/tst-thread-quick_exit.cc                      |  2 +-
 string/tst-xbzero-opt.c                              |  3 ++-
 sysdeps/generic/tst-stack-align.h                    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c  |  2 +-
 .../unix/sysv/linux/x86_64/tst-cet-setcontext-1.c    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c     |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c              |  2 +-
 sysdeps/x86/tst-memchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memset-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c                        |  8 ++++----
 sysdeps/x86/tst-strrchr-rtm.c                        |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c                      |  2 +-
 44 files changed, 112 insertions(+), 100 deletions(-)

diff --git a/benchtests/bench-hash-funcs-kernel.h b/benchtests/bench-hash-funcs-kernel.h
index 7eaa3665b6..aee1f1cdc8 100644
--- a/benchtests/bench-hash-funcs-kernel.h
+++ b/benchtests/bench-hash-funcs-kernel.h
@@ -35,7 +35,7 @@
 #define PRIMITIVE_CAT(x, y) x ## y
 #define CAT(x, y) PRIMITIVE_CAT (x, y)
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
 {
 
@@ -58,7 +58,7 @@ CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
   return (double) cur / (double) NFIXED_ITERS;
 }
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_rand_test_kernel, POSTFIX) (char const *bufs,
 				    unsigned int const *sizes)
 {
diff --git a/benchtests/bench-hash-funcs.c b/benchtests/bench-hash-funcs.c
index 8dd88c9e39..ca199a7fae 100644
--- a/benchtests/bench-hash-funcs.c
+++ b/benchtests/bench-hash-funcs.c
@@ -67,7 +67,7 @@ do_one_test (json_ctx_t *json_ctx, size_t len)
   json_element_object_end (json_ctx);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_rand_test (json_ctx_t *json_ctx)
 {
   size_t i, sz, offset;
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index eed6882085..5ef3a9d438 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 53239dad59..5526cb2dc3 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index a1e4fb0630..27f10edc56 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index d6930b9f16..3f90212e07 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 9de4e7f85f..e379cced86 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 0e60f7e2e6..5fa98f3b38 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index aec3897087..d21191a53d 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index f698871876..d5bc3433e7 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index f72e1a1b28..25e3e31521 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 2e8279a2c7..d1f411a57a 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -874,4 +874,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index d060b125c9..4418b1867a 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index b729091ec4..34b4bde825 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index b3b6989268..28cd769198 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 270520528c..c6d5ec2e66 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index e54b3e1ff2..b3187a5aa8 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index 4331d80383..22789fe084 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext10.c b/stdlib/tst-setcontext10.c
index 7267f5efe3..65a7e53f0a 100644
--- a/stdlib/tst-setcontext10.c
+++ b/stdlib/tst-setcontext10.c
@@ -37,7 +37,7 @@ static ucontext_t ctx;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -45,7 +45,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
@@ -64,7 +64,7 @@ f3 (void)
 }
 
 static int
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 do_test_1 (void)
 {
   char st1[32768];
diff --git a/stdlib/tst-setcontext11.c b/stdlib/tst-setcontext11.c
index 1883c44b76..c768782b86 100644
--- a/stdlib/tst-setcontext11.c
+++ b/stdlib/tst-setcontext11.c
@@ -54,7 +54,7 @@ f1 (int a0, int a1, int a2, int a3)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 call_longjmp (void)
 {
   longjmp_called = 1;
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 9b29907a13..42e87e2185 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index cdcf5eb871..d02cade70c 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 91b6255138..579d45419a 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index c96b8a27a8..e10d76fe4f 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-swapcontext2.c b/stdlib/tst-swapcontext2.c
index f679755649..9c7440ff11 100644
--- a/stdlib/tst-swapcontext2.c
+++ b/stdlib/tst-swapcontext2.c
@@ -32,7 +32,7 @@ static jmp_buf jmpbuf;
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -42,7 +42,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -51,7 +51,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -67,7 +67,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index dadccee334..a4dc03d661 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 2392eaa2c1..954fc61f89 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 12473e32b8..5b622f5a3f 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
index 5274a09509..a72ace740a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
@@ -25,7 +25,7 @@
 extern void bar (void);
 
 void
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 test (void (*func_p) (void))
 {
   func_p ();
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
index 388931f5f3..c0289dc701 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
@@ -30,7 +30,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
index 56d77530ae..3e0061f605 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
@@ -25,7 +25,7 @@
 #include <x86intrin.h>
 #include <support/test-driver.h>
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 do_test_1 (void)
 {
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 3a60750de4..581c9c1fc4 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 7dc0718b7c..fb57bc115a 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 124eb17aed..24df5ed79a 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index dfb5533784..8ff1940109 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 48512de7f4..13ed0aed45 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 60e714c757..3eb6388b74 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 8294cc5118..e9689f0f7c 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index c2274a5d3e..8d1453caa5 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 139f52004e..cb5c340448 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 5b083f29dc..278cf27c8c 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index ebc8837ad1..3529431527 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
@@ -72,7 +72,7 @@ function_overflow (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow2 (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 487d2071d4..35f328e294 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 2c424ffe94..b367e75177 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2024-04-02 15:55 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 15:55 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ef1a19e05d5d265e1ea9917e8be83575bdb54908

commit ef1a19e05d5d265e1ea9917e8be83575bdb54908
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-hash-funcs-kernel.h                 |  4 ++--
 benchtests/bench-hash-funcs.c                        |  2 +-
 benchtests/bench-strchr.c                            |  4 ++--
 debug/tst-backtrace.h                                |  2 +-
 debug/tst-ssp-1.c                                    |  2 +-
 elf/tst-p_alignmod-base.c                            |  2 +-
 gmon/tst-gmon.c                                      |  8 +++++---
 gmon/tst-mcount-overflow.c                           | 10 ++++++----
 malloc/tst-malloc-thread-exit.c                      |  2 +-
 malloc/tst-malloc-thread-fail.c                      |  2 +-
 malloc/tst-mallocstate.c                             |  2 +-
 misc/sys/cdefs.h                                     |  7 +++++++
 misc/tst-syscalls.c                                  | 14 +++++++-------
 nptl/tst-minstack-throw.cc                           |  8 ++++----
 nptl/tst-thread-exit-clobber.cc                      | 12 ++++++------
 nptl/tst-thread_local1.cc                            | 12 ++++++------
 stdlib/tst-makecontext-align.c                       | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                             |  2 +-
 stdlib/tst-setcontext10.c                            |  6 +++---
 stdlib/tst-setcontext11.c                            |  2 +-
 stdlib/tst-setcontext5.c                             |  4 ++--
 stdlib/tst-setcontext8.c                             |  2 +-
 stdlib/tst-setcontext9.c                             |  2 +-
 stdlib/tst-swapcontext1.c                            |  8 ++++----
 stdlib/tst-swapcontext2.c                            |  8 ++++----
 stdlib/tst-thread-quick_exit.cc                      |  2 +-
 string/tst-xbzero-opt.c                              |  3 ++-
 sysdeps/generic/tst-stack-align.h                    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c  |  2 +-
 .../unix/sysv/linux/x86_64/tst-cet-setcontext-1.c    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c     |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c              |  2 +-
 sysdeps/x86/tst-memchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memset-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c                        |  8 ++++----
 sysdeps/x86/tst-strrchr-rtm.c                        |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c                      |  2 +-
 44 files changed, 112 insertions(+), 100 deletions(-)

diff --git a/benchtests/bench-hash-funcs-kernel.h b/benchtests/bench-hash-funcs-kernel.h
index 7eaa3665b6..aee1f1cdc8 100644
--- a/benchtests/bench-hash-funcs-kernel.h
+++ b/benchtests/bench-hash-funcs-kernel.h
@@ -35,7 +35,7 @@
 #define PRIMITIVE_CAT(x, y) x ## y
 #define CAT(x, y) PRIMITIVE_CAT (x, y)
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
 {
 
@@ -58,7 +58,7 @@ CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
   return (double) cur / (double) NFIXED_ITERS;
 }
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_rand_test_kernel, POSTFIX) (char const *bufs,
 				    unsigned int const *sizes)
 {
diff --git a/benchtests/bench-hash-funcs.c b/benchtests/bench-hash-funcs.c
index 8dd88c9e39..ca199a7fae 100644
--- a/benchtests/bench-hash-funcs.c
+++ b/benchtests/bench-hash-funcs.c
@@ -67,7 +67,7 @@ do_one_test (json_ctx_t *json_ctx, size_t len)
   json_element_object_end (json_ctx);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_rand_test (json_ctx_t *json_ctx)
 {
   size_t i, sz, offset;
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index eed6882085..5ef3a9d438 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 53239dad59..5526cb2dc3 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index a1e4fb0630..27f10edc56 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index d6930b9f16..3f90212e07 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 9de4e7f85f..e379cced86 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 0e60f7e2e6..5fa98f3b38 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index aec3897087..d21191a53d 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index f698871876..d5bc3433e7 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index f72e1a1b28..25e3e31521 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 2e8279a2c7..d1f411a57a 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -874,4 +874,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index d060b125c9..4418b1867a 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index b729091ec4..34b4bde825 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index b3b6989268..28cd769198 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 270520528c..c6d5ec2e66 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index e54b3e1ff2..b3187a5aa8 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index 4331d80383..22789fe084 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext10.c b/stdlib/tst-setcontext10.c
index 7267f5efe3..65a7e53f0a 100644
--- a/stdlib/tst-setcontext10.c
+++ b/stdlib/tst-setcontext10.c
@@ -37,7 +37,7 @@ static ucontext_t ctx;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -45,7 +45,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
@@ -64,7 +64,7 @@ f3 (void)
 }
 
 static int
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 do_test_1 (void)
 {
   char st1[32768];
diff --git a/stdlib/tst-setcontext11.c b/stdlib/tst-setcontext11.c
index 1883c44b76..c768782b86 100644
--- a/stdlib/tst-setcontext11.c
+++ b/stdlib/tst-setcontext11.c
@@ -54,7 +54,7 @@ f1 (int a0, int a1, int a2, int a3)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 call_longjmp (void)
 {
   longjmp_called = 1;
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 9b29907a13..42e87e2185 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index cdcf5eb871..d02cade70c 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 91b6255138..579d45419a 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index c96b8a27a8..e10d76fe4f 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-swapcontext2.c b/stdlib/tst-swapcontext2.c
index f679755649..9c7440ff11 100644
--- a/stdlib/tst-swapcontext2.c
+++ b/stdlib/tst-swapcontext2.c
@@ -32,7 +32,7 @@ static jmp_buf jmpbuf;
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -42,7 +42,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -51,7 +51,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -67,7 +67,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index dadccee334..a4dc03d661 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 2392eaa2c1..954fc61f89 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 12473e32b8..5b622f5a3f 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
index 5274a09509..a72ace740a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
@@ -25,7 +25,7 @@
 extern void bar (void);
 
 void
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 test (void (*func_p) (void))
 {
   func_p ();
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
index 388931f5f3..c0289dc701 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
@@ -30,7 +30,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
index 56d77530ae..3e0061f605 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
@@ -25,7 +25,7 @@
 #include <x86intrin.h>
 #include <support/test-driver.h>
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 do_test_1 (void)
 {
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 3a60750de4..581c9c1fc4 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 7dc0718b7c..fb57bc115a 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 124eb17aed..24df5ed79a 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index dfb5533784..8ff1940109 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 48512de7f4..13ed0aed45 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 60e714c757..3eb6388b74 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 8294cc5118..e9689f0f7c 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index c2274a5d3e..8d1453caa5 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 139f52004e..cb5c340448 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 5b083f29dc..278cf27c8c 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index ebc8837ad1..3529431527 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
@@ -72,7 +72,7 @@ function_overflow (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow2 (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 487d2071d4..35f328e294 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 2c424ffe94..b367e75177 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2024-02-09 17:33 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:33 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=62c2a234853701c7a4736b5a70051ee6bf7c34f9

commit 62c2a234853701c7a4736b5a70051ee6bf7c34f9
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-hash-funcs-kernel.h                 |  4 ++--
 benchtests/bench-hash-funcs.c                        |  2 +-
 benchtests/bench-strchr.c                            |  4 ++--
 debug/tst-backtrace.h                                |  2 +-
 debug/tst-ssp-1.c                                    |  2 +-
 elf/tst-p_alignmod-base.c                            |  2 +-
 gmon/tst-gmon.c                                      |  8 +++++---
 gmon/tst-mcount-overflow.c                           | 10 ++++++----
 malloc/tst-malloc-thread-exit.c                      |  2 +-
 malloc/tst-malloc-thread-fail.c                      |  2 +-
 malloc/tst-mallocstate.c                             |  2 +-
 misc/sys/cdefs.h                                     |  7 +++++++
 misc/tst-syscalls.c                                  | 14 +++++++-------
 nptl/tst-minstack-throw.cc                           |  8 ++++----
 nptl/tst-thread-exit-clobber.cc                      | 12 ++++++------
 nptl/tst-thread_local1.cc                            | 12 ++++++------
 stdlib/tst-makecontext-align.c                       | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                             |  2 +-
 stdlib/tst-setcontext10.c                            |  6 +++---
 stdlib/tst-setcontext11.c                            |  2 +-
 stdlib/tst-setcontext5.c                             |  4 ++--
 stdlib/tst-setcontext8.c                             |  2 +-
 stdlib/tst-setcontext9.c                             |  2 +-
 stdlib/tst-swapcontext1.c                            |  8 ++++----
 stdlib/tst-swapcontext2.c                            |  8 ++++----
 stdlib/tst-thread-quick_exit.cc                      |  2 +-
 string/tst-xbzero-opt.c                              |  3 ++-
 sysdeps/generic/tst-stack-align.h                    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c  |  2 +-
 .../unix/sysv/linux/x86_64/tst-cet-setcontext-1.c    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c     |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c              |  2 +-
 sysdeps/x86/tst-memchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memset-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c                        |  8 ++++----
 sysdeps/x86/tst-strrchr-rtm.c                        |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c                      |  2 +-
 44 files changed, 112 insertions(+), 100 deletions(-)

diff --git a/benchtests/bench-hash-funcs-kernel.h b/benchtests/bench-hash-funcs-kernel.h
index 7eaa3665b6..aee1f1cdc8 100644
--- a/benchtests/bench-hash-funcs-kernel.h
+++ b/benchtests/bench-hash-funcs-kernel.h
@@ -35,7 +35,7 @@
 #define PRIMITIVE_CAT(x, y) x ## y
 #define CAT(x, y) PRIMITIVE_CAT (x, y)
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
 {
 
@@ -58,7 +58,7 @@ CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
   return (double) cur / (double) NFIXED_ITERS;
 }
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_rand_test_kernel, POSTFIX) (char const *bufs,
 				    unsigned int const *sizes)
 {
diff --git a/benchtests/bench-hash-funcs.c b/benchtests/bench-hash-funcs.c
index 8dd88c9e39..ca199a7fae 100644
--- a/benchtests/bench-hash-funcs.c
+++ b/benchtests/bench-hash-funcs.c
@@ -67,7 +67,7 @@ do_one_test (json_ctx_t *json_ctx, size_t len)
   json_element_object_end (json_ctx);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_rand_test (json_ctx_t *json_ctx)
 {
   size_t i, sz, offset;
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index eed6882085..5ef3a9d438 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 53239dad59..5526cb2dc3 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index a1e4fb0630..27f10edc56 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index d6930b9f16..3f90212e07 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 9de4e7f85f..e379cced86 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 0e60f7e2e6..5fa98f3b38 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index aec3897087..d21191a53d 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index f698871876..d5bc3433e7 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index f72e1a1b28..25e3e31521 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 6b03417453..7930f2f5b2 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -874,4 +874,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index d060b125c9..4418b1867a 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index b729091ec4..34b4bde825 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index b3b6989268..28cd769198 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 270520528c..c6d5ec2e66 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index e54b3e1ff2..b3187a5aa8 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index 4331d80383..22789fe084 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext10.c b/stdlib/tst-setcontext10.c
index 7267f5efe3..65a7e53f0a 100644
--- a/stdlib/tst-setcontext10.c
+++ b/stdlib/tst-setcontext10.c
@@ -37,7 +37,7 @@ static ucontext_t ctx;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -45,7 +45,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
@@ -64,7 +64,7 @@ f3 (void)
 }
 
 static int
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 do_test_1 (void)
 {
   char st1[32768];
diff --git a/stdlib/tst-setcontext11.c b/stdlib/tst-setcontext11.c
index 1883c44b76..c768782b86 100644
--- a/stdlib/tst-setcontext11.c
+++ b/stdlib/tst-setcontext11.c
@@ -54,7 +54,7 @@ f1 (int a0, int a1, int a2, int a3)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 call_longjmp (void)
 {
   longjmp_called = 1;
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 9b29907a13..42e87e2185 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index cdcf5eb871..d02cade70c 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 91b6255138..579d45419a 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index c96b8a27a8..e10d76fe4f 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-swapcontext2.c b/stdlib/tst-swapcontext2.c
index f679755649..9c7440ff11 100644
--- a/stdlib/tst-swapcontext2.c
+++ b/stdlib/tst-swapcontext2.c
@@ -32,7 +32,7 @@ static jmp_buf jmpbuf;
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -42,7 +42,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -51,7 +51,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -67,7 +67,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index dadccee334..a4dc03d661 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 2392eaa2c1..954fc61f89 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 12473e32b8..5b622f5a3f 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
index 5274a09509..a72ace740a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
@@ -25,7 +25,7 @@
 extern void bar (void);
 
 void
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 test (void (*func_p) (void))
 {
   func_p ();
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
index 388931f5f3..c0289dc701 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
@@ -30,7 +30,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
index 56d77530ae..3e0061f605 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
@@ -25,7 +25,7 @@
 #include <x86intrin.h>
 #include <support/test-driver.h>
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 do_test_1 (void)
 {
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 3a60750de4..581c9c1fc4 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 7dc0718b7c..fb57bc115a 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 124eb17aed..24df5ed79a 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index dfb5533784..8ff1940109 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 48512de7f4..13ed0aed45 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 60e714c757..3eb6388b74 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 8294cc5118..e9689f0f7c 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index c2274a5d3e..8d1453caa5 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 139f52004e..cb5c340448 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 5b083f29dc..278cf27c8c 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index ebc8837ad1..3529431527 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
@@ -72,7 +72,7 @@ function_overflow (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow2 (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 487d2071d4..35f328e294 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 2c424ffe94..b367e75177 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2024-02-07 14:09 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:09 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=09e214a177ab4795475c0a2f3ba0a136e7d2ebbc

commit 09e214a177ab4795475c0a2f3ba0a136e7d2ebbc
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-hash-funcs-kernel.h                 |  4 ++--
 benchtests/bench-hash-funcs.c                        |  2 +-
 benchtests/bench-strchr.c                            |  4 ++--
 debug/tst-backtrace.h                                |  2 +-
 debug/tst-ssp-1.c                                    |  2 +-
 elf/tst-p_alignmod-base.c                            |  2 +-
 gmon/tst-gmon.c                                      |  8 +++++---
 gmon/tst-mcount-overflow.c                           | 10 ++++++----
 malloc/tst-malloc-thread-exit.c                      |  2 +-
 malloc/tst-malloc-thread-fail.c                      |  2 +-
 malloc/tst-mallocstate.c                             |  2 +-
 misc/sys/cdefs.h                                     |  7 +++++++
 misc/tst-syscalls.c                                  | 14 +++++++-------
 nptl/tst-minstack-throw.cc                           |  8 ++++----
 nptl/tst-thread-exit-clobber.cc                      | 12 ++++++------
 nptl/tst-thread_local1.cc                            | 12 ++++++------
 stdlib/tst-makecontext-align.c                       | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                             |  2 +-
 stdlib/tst-setcontext10.c                            |  6 +++---
 stdlib/tst-setcontext11.c                            |  2 +-
 stdlib/tst-setcontext5.c                             |  4 ++--
 stdlib/tst-setcontext8.c                             |  2 +-
 stdlib/tst-setcontext9.c                             |  2 +-
 stdlib/tst-swapcontext1.c                            |  8 ++++----
 stdlib/tst-swapcontext2.c                            |  8 ++++----
 stdlib/tst-thread-quick_exit.cc                      |  2 +-
 string/tst-xbzero-opt.c                              |  3 ++-
 sysdeps/generic/tst-stack-align.h                    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c  |  2 +-
 .../unix/sysv/linux/x86_64/tst-cet-setcontext-1.c    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c     |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c              |  2 +-
 sysdeps/x86/tst-memchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memset-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c                        |  8 ++++----
 sysdeps/x86/tst-strrchr-rtm.c                        |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c                      |  2 +-
 44 files changed, 112 insertions(+), 100 deletions(-)

diff --git a/benchtests/bench-hash-funcs-kernel.h b/benchtests/bench-hash-funcs-kernel.h
index 7eaa3665b6..aee1f1cdc8 100644
--- a/benchtests/bench-hash-funcs-kernel.h
+++ b/benchtests/bench-hash-funcs-kernel.h
@@ -35,7 +35,7 @@
 #define PRIMITIVE_CAT(x, y) x ## y
 #define CAT(x, y) PRIMITIVE_CAT (x, y)
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
 {
 
@@ -58,7 +58,7 @@ CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len)
   return (double) cur / (double) NFIXED_ITERS;
 }
 
-static double __attribute__ ((noinline, noclone))
+static double __attribute__ ((noinline)) __attribute_noclone__
 CAT (do_rand_test_kernel, POSTFIX) (char const *bufs,
 				    unsigned int const *sizes)
 {
diff --git a/benchtests/bench-hash-funcs.c b/benchtests/bench-hash-funcs.c
index 8dd88c9e39..ca199a7fae 100644
--- a/benchtests/bench-hash-funcs.c
+++ b/benchtests/bench-hash-funcs.c
@@ -67,7 +67,7 @@ do_one_test (json_ctx_t *json_ctx, size_t len)
   json_element_object_end (json_ctx);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_rand_test (json_ctx_t *json_ctx)
 {
   size_t i, sz, offset;
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index eed6882085..5ef3a9d438 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 53239dad59..5526cb2dc3 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index a1e4fb0630..27f10edc56 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index d6930b9f16..3f90212e07 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 9de4e7f85f..e379cced86 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 0e60f7e2e6..5fa98f3b38 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index aec3897087..d21191a53d 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index f698871876..d5bc3433e7 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index f72e1a1b28..25e3e31521 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 6b03417453..7930f2f5b2 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -874,4 +874,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index d060b125c9..4418b1867a 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index b729091ec4..34b4bde825 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index b3b6989268..28cd769198 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 270520528c..c6d5ec2e66 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index e54b3e1ff2..b3187a5aa8 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index 4331d80383..22789fe084 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext10.c b/stdlib/tst-setcontext10.c
index 7267f5efe3..65a7e53f0a 100644
--- a/stdlib/tst-setcontext10.c
+++ b/stdlib/tst-setcontext10.c
@@ -37,7 +37,7 @@ static ucontext_t ctx;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -45,7 +45,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
@@ -64,7 +64,7 @@ f3 (void)
 }
 
 static int
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 do_test_1 (void)
 {
   char st1[32768];
diff --git a/stdlib/tst-setcontext11.c b/stdlib/tst-setcontext11.c
index 1883c44b76..c768782b86 100644
--- a/stdlib/tst-setcontext11.c
+++ b/stdlib/tst-setcontext11.c
@@ -54,7 +54,7 @@ f1 (int a0, int a1, int a2, int a3)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 call_longjmp (void)
 {
   longjmp_called = 1;
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 9b29907a13..42e87e2185 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index cdcf5eb871..d02cade70c 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 91b6255138..579d45419a 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index c96b8a27a8..e10d76fe4f 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-swapcontext2.c b/stdlib/tst-swapcontext2.c
index f679755649..9c7440ff11 100644
--- a/stdlib/tst-swapcontext2.c
+++ b/stdlib/tst-swapcontext2.c
@@ -32,7 +32,7 @@ static jmp_buf jmpbuf;
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -42,7 +42,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -51,7 +51,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -67,7 +67,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index dadccee334..a4dc03d661 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 2392eaa2c1..954fc61f89 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 12473e32b8..5b622f5a3f 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
index 5274a09509..a72ace740a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
@@ -25,7 +25,7 @@
 extern void bar (void);
 
 void
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 test (void (*func_p) (void))
 {
   func_p ();
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
index 388931f5f3..c0289dc701 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
@@ -30,7 +30,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
index 56d77530ae..3e0061f605 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
@@ -25,7 +25,7 @@
 #include <x86intrin.h>
 #include <support/test-driver.h>
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 do_test_1 (void)
 {
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 3a60750de4..581c9c1fc4 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 7dc0718b7c..fb57bc115a 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 124eb17aed..24df5ed79a 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index dfb5533784..8ff1940109 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 48512de7f4..13ed0aed45 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 60e714c757..3eb6388b74 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 8294cc5118..e9689f0f7c 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index c2274a5d3e..8d1453caa5 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 139f52004e..cb5c340448 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 5b083f29dc..278cf27c8c 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index ebc8837ad1..3529431527 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
@@ -72,7 +72,7 @@ function_overflow (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow2 (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 487d2071d4..35f328e294 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 2c424ffe94..b367e75177 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2024-01-29 17:59 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2024-01-29 17:59 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=cce005c2495c4707156d4c921cbae209fd6d0751

commit cce005c2495c4707156d4c921cbae209fd6d0751
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c                            |  4 ++--
 debug/tst-backtrace.h                                |  2 +-
 debug/tst-ssp-1.c                                    |  2 +-
 elf/tst-p_alignmod-base.c                            |  2 +-
 gmon/tst-gmon.c                                      |  8 +++++---
 gmon/tst-mcount-overflow.c                           | 10 ++++++----
 malloc/tst-malloc-thread-exit.c                      |  2 +-
 malloc/tst-malloc-thread-fail.c                      |  2 +-
 malloc/tst-mallocstate.c                             |  2 +-
 misc/sys/cdefs.h                                     |  7 +++++++
 misc/tst-syscalls.c                                  | 14 +++++++-------
 nptl/tst-minstack-throw.cc                           |  8 ++++----
 nptl/tst-thread-exit-clobber.cc                      | 12 ++++++------
 nptl/tst-thread_local1.cc                            | 12 ++++++------
 stdlib/tst-makecontext-align.c                       | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                             |  2 +-
 stdlib/tst-setcontext10.c                            |  6 +++---
 stdlib/tst-setcontext11.c                            |  2 +-
 stdlib/tst-setcontext5.c                             |  4 ++--
 stdlib/tst-setcontext8.c                             |  2 +-
 stdlib/tst-setcontext9.c                             |  2 +-
 stdlib/tst-swapcontext1.c                            |  8 ++++----
 stdlib/tst-swapcontext2.c                            |  8 ++++----
 stdlib/tst-thread-quick_exit.cc                      |  2 +-
 string/tst-xbzero-opt.c                              |  3 ++-
 sysdeps/generic/tst-stack-align.h                    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c  |  2 +-
 .../unix/sysv/linux/x86_64/tst-cet-setcontext-1.c    |  2 +-
 sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c     |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c              |  2 +-
 sysdeps/x86/tst-memchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c                        |  4 ++--
 sysdeps/x86/tst-memset-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c                         |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c                        |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c                        |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c                      |  2 +-
 42 files changed, 108 insertions(+), 96 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index eed6882085..5ef3a9d438 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 53239dad59..5526cb2dc3 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index a1e4fb0630..27f10edc56 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index d6930b9f16..3f90212e07 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 9de4e7f85f..e379cced86 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 0e60f7e2e6..5fa98f3b38 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index aec3897087..d21191a53d 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index f698871876..d5bc3433e7 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index f72e1a1b28..25e3e31521 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 6b03417453..7930f2f5b2 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -874,4 +874,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index d060b125c9..4418b1867a 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index b729091ec4..34b4bde825 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index b3b6989268..28cd769198 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 270520528c..c6d5ec2e66 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index e54b3e1ff2..b3187a5aa8 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index 4331d80383..22789fe084 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext10.c b/stdlib/tst-setcontext10.c
index 7267f5efe3..65a7e53f0a 100644
--- a/stdlib/tst-setcontext10.c
+++ b/stdlib/tst-setcontext10.c
@@ -37,7 +37,7 @@ static ucontext_t ctx;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -45,7 +45,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
@@ -64,7 +64,7 @@ f3 (void)
 }
 
 static int
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 do_test_1 (void)
 {
   char st1[32768];
diff --git a/stdlib/tst-setcontext11.c b/stdlib/tst-setcontext11.c
index 1883c44b76..c768782b86 100644
--- a/stdlib/tst-setcontext11.c
+++ b/stdlib/tst-setcontext11.c
@@ -54,7 +54,7 @@ f1 (int a0, int a1, int a2, int a3)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 call_longjmp (void)
 {
   longjmp_called = 1;
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 9b29907a13..42e87e2185 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index cdcf5eb871..d02cade70c 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 91b6255138..579d45419a 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index c96b8a27a8..e10d76fe4f 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-swapcontext2.c b/stdlib/tst-swapcontext2.c
index f679755649..9c7440ff11 100644
--- a/stdlib/tst-swapcontext2.c
+++ b/stdlib/tst-swapcontext2.c
@@ -32,7 +32,7 @@ static jmp_buf jmpbuf;
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -42,7 +42,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -51,7 +51,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -67,7 +67,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index dadccee334..a4dc03d661 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 2392eaa2c1..954fc61f89 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 12473e32b8..5b622f5a3f 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
index 5274a09509..a72ace740a 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-property-2.c
@@ -25,7 +25,7 @@
 extern void bar (void);
 
 void
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 test (void (*func_p) (void))
 {
   func_p ();
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
index 388931f5f3..c0289dc701 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-setcontext-1.c
@@ -30,7 +30,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
index 56d77530ae..3e0061f605 100644
--- a/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
+++ b/sysdeps/unix/sysv/linux/x86_64/tst-cet-vfork-1.c
@@ -25,7 +25,7 @@
 #include <x86intrin.h>
 #include <support/test-driver.h>
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 do_test_1 (void)
 {
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 3a60750de4..581c9c1fc4 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 7dc0718b7c..fb57bc115a 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 124eb17aed..24df5ed79a 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index dfb5533784..8ff1940109 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 48512de7f4..13ed0aed45 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 60e714c757..3eb6388b74 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 8294cc5118..e9689f0f7c 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index c2274a5d3e..8d1453caa5 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 139f52004e..cb5c340448 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 5b083f29dc..278cf27c8c 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index ebc8837ad1..295b2c7520 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 487d2071d4..35f328e294 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 2c424ffe94..b367e75177 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2023-12-21 18:55 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-12-21 18:55 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4c5731b09cdc4d9bb0d2875a1c97af68967296e8

commit 4c5731b09cdc4d9bb0d2875a1c97af68967296e8
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c                          |  4 ++--
 debug/tst-backtrace.h                              |  2 +-
 debug/tst-ssp-1.c                                  |  2 +-
 elf/tst-p_alignmod-base.c                          |  2 +-
 gmon/tst-gmon.c                                    |  8 +++++---
 gmon/tst-mcount-overflow.c                         | 10 ++++++----
 malloc/tst-malloc-thread-exit.c                    |  2 +-
 malloc/tst-malloc-thread-fail.c                    |  2 +-
 malloc/tst-mallocstate.c                           |  2 +-
 misc/sys/cdefs.h                                   |  7 +++++++
 misc/tst-syscalls.c                                | 14 +++++++-------
 nptl/tst-minstack-throw.cc                         |  8 ++++----
 nptl/tst-thread-exit-clobber.cc                    | 12 ++++++------
 nptl/tst-thread_local1.cc                          | 12 ++++++------
 stdlib/tst-makecontext-align.c                     | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                           |  2 +-
 stdlib/tst-setcontext10.c                          |  6 +++---
 stdlib/tst-setcontext11.c                          |  2 +-
 stdlib/tst-setcontext5.c                           |  4 ++--
 stdlib/tst-setcontext8.c                           |  2 +-
 stdlib/tst-setcontext9.c                           |  2 +-
 stdlib/tst-swapcontext1.c                          |  8 ++++----
 stdlib/tst-thread-quick_exit.cc                    |  2 +-
 string/tst-xbzero-opt.c                            |  3 ++-
 sysdeps/generic/tst-stack-align.h                  |  2 +-
 sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c   |  2 +-
 sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c |  2 +-
 sysdeps/unix/sysv/linux/x86/tst-cet-vfork-1.c      |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c            |  2 +-
 sysdeps/x86/tst-memchr-rtm.c                       |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c                       |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c                      |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c                      |  4 ++--
 sysdeps/x86/tst-memset-rtm.c                       |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c                       |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c                       |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c                       |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c                       |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c                      |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c                      |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c                    |  2 +-
 41 files changed, 104 insertions(+), 92 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 116ec19760..030261c953 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 33acadeeaa..cafa643834 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index 030a9d0a9c..746e24f33a 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 531ca0104f..70d616dd82 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 654441ee30..0dc5db40d9 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 06cc93ef87..d95e6c9ad4 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index fdc68cc483..9b2ea73d63 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 271941bb8e..743ae66280 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index 340a394d1a..cb6b84cd00 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index a9022621e2..73912dfa17 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -865,4 +865,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 493091ccd4..d16f1e7c83 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index 5a3a131002..c9917a29fc 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index eabf3f3391..b5fbfc033e 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index e7cd0e3102..0b6e1d7343 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index d6b3df0762..e5a8cb9c2e 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index c80cb7c352..d0c05fda14 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext10.c b/stdlib/tst-setcontext10.c
index d714563742..5c2ac456b3 100644
--- a/stdlib/tst-setcontext10.c
+++ b/stdlib/tst-setcontext10.c
@@ -37,7 +37,7 @@ static ucontext_t ctx;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -45,7 +45,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
@@ -64,7 +64,7 @@ f3 (void)
 }
 
 static int
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 do_test_1 (void)
 {
   char st1[32768];
diff --git a/stdlib/tst-setcontext11.c b/stdlib/tst-setcontext11.c
index 5f5df5b81b..02497412ae 100644
--- a/stdlib/tst-setcontext11.c
+++ b/stdlib/tst-setcontext11.c
@@ -54,7 +54,7 @@ f1 (int a0, int a1, int a2, int a3)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 call_longjmp (void)
 {
   longjmp_called = 1;
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 77f73e10ae..c7a6dff329 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 06230377cd..535c31948b 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 6546a27fad..93cf1fb213 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 39a47365cd..99258332ef 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 03e3c94d8a..89b9a63159 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 4e8ba30373..abcaf43bd3 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 9926fefa8c..67c4d9cac0 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c b/sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c
index 349c6a7022..553d5f3793 100644
--- a/sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c
+++ b/sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c
@@ -25,7 +25,7 @@
 extern void bar (void);
 
 void
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 test (void (*func_p) (void))
 {
   func_p ();
diff --git a/sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c b/sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c
index 837a9fd0eb..6ced96ce2a 100644
--- a/sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c
+++ b/sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c
@@ -30,7 +30,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/sysdeps/unix/sysv/linux/x86/tst-cet-vfork-1.c b/sysdeps/unix/sysv/linux/x86/tst-cet-vfork-1.c
index c92ed9e737..16947844cc 100644
--- a/sysdeps/unix/sysv/linux/x86/tst-cet-vfork-1.c
+++ b/sysdeps/unix/sysv/linux/x86/tst-cet-vfork-1.c
@@ -25,7 +25,7 @@
 #include <x86intrin.h>
 #include <support/test-driver.h>
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 do_test_1 (void)
 {
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index f3a83b86a6..daa39026dc 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index e6de5e71b9..0e3a5fe1a6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 3ec7343ebe..d541630b31 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index cb39c9cc86..60ea31945f 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index fc6a72814e..30c6c7ad57 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index c64fbf6637..c49bfcb815 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 00951b5098..345adbbc54 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index 459665143a..9b075a8981 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 93b3b8fbae..0df197ddc9 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index bca62c3754..44ca9e5b63 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index 12de624f30..af80f2ca76 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 9b12f7d29d..ddd3a4caca 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 87ffbe24de..0165fc3db1 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2023-09-28 17:54 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-09-28 17:54 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d98add2b5217a856db43d967668537e260ac0c20

commit d98add2b5217a856db43d967668537e260ac0c20
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 gmon/tst-mcount-overflow.c              | 10 ++++++----
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 36 files changed, 97 insertions(+), 85 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 116ec19760..030261c953 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 33acadeeaa..cafa643834 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index 030a9d0a9c..746e24f33a 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 531ca0104f..70d616dd82 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 654441ee30..0dc5db40d9 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 06cc93ef87..d95e6c9ad4 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index fdc68cc483..9b2ea73d63 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 271941bb8e..743ae66280 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index 340a394d1a..cb6b84cd00 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 90c21e2703..ec8102845b 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -720,4 +720,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 493091ccd4..d16f1e7c83 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index 5a3a131002..c9917a29fc 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index eabf3f3391..b5fbfc033e 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index e7cd0e3102..0b6e1d7343 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index d6b3df0762..e5a8cb9c2e 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index c80cb7c352..d0c05fda14 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 77f73e10ae..c7a6dff329 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 06230377cd..535c31948b 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 6546a27fad..93cf1fb213 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 39a47365cd..99258332ef 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 03e3c94d8a..89b9a63159 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 4e8ba30373..abcaf43bd3 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 9926fefa8c..67c4d9cac0 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index f3a83b86a6..daa39026dc 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index e6de5e71b9..0e3a5fe1a6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 3ec7343ebe..d541630b31 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index cb39c9cc86..60ea31945f 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index fc6a72814e..30c6c7ad57 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index c64fbf6637..c49bfcb815 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 00951b5098..345adbbc54 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index 459665143a..9b075a8981 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 93b3b8fbae..0df197ddc9 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index bca62c3754..44ca9e5b63 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index 12de624f30..af80f2ca76 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 9b12f7d29d..ddd3a4caca 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 87ffbe24de..0165fc3db1 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2023-08-30 12:38 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-08-30 12:38 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=13bced10c45594480a29110a2005e70b2a4decb8

commit 13bced10c45594480a29110a2005e70b2a4decb8
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 gmon/tst-mcount-overflow.c              | 10 ++++++----
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 36 files changed, 97 insertions(+), 85 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 116ec19760..030261c953 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -117,7 +117,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 33acadeeaa..cafa643834 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index 030a9d0a9c..746e24f33a 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 531ca0104f..70d616dd82 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 654441ee30..0dc5db40d9 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/gmon/tst-mcount-overflow.c b/gmon/tst-mcount-overflow.c
index 06cc93ef87..d95e6c9ad4 100644
--- a/gmon/tst-mcount-overflow.c
+++ b/gmon/tst-mcount-overflow.c
@@ -16,6 +16,8 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* Program with sufficiently complex, yet pointless, call graph
    that it will trigger an mcount overflow, when you set the
    minarcs/maxarcs tunables to very low values. */
@@ -31,12 +33,12 @@
 
 /* Defines 16 leaf functions named f1_0 to f1_15 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void f1_##n (void) {};
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void f1_##n (void) {};
 REPS
 #undef REP
 
 /* Calls all 16 leaf functions f1_* in succession */
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
 # define REP(n) f1_##n();
@@ -47,12 +49,12 @@ f2 (void)
 
 /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
 #define REP(n) \
-  __attribute__ ((noinline, noclone, weak)) void \
+  __attribute__ ((noinline, weak)) __attribute_noclone__ void \
   f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
 REPS
 #undef REP
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index fdc68cc483..9b2ea73d63 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 271941bb8e..743ae66280 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index 340a394d1a..cb6b84cd00 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 90c21e2703..ec8102845b 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -720,4 +720,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 493091ccd4..d16f1e7c83 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index 5a3a131002..c9917a29fc 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index eabf3f3391..b5fbfc033e 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index e7cd0e3102..0b6e1d7343 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index d6b3df0762..e5a8cb9c2e 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index c80cb7c352..d0c05fda14 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 77f73e10ae..c7a6dff329 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 06230377cd..535c31948b 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 6546a27fad..93cf1fb213 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 39a47365cd..99258332ef 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 03e3c94d8a..89b9a63159 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 4e8ba30373..abcaf43bd3 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 9926fefa8c..67c4d9cac0 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index f3a83b86a6..daa39026dc 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index e6de5e71b9..0e3a5fe1a6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 3ec7343ebe..d541630b31 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index cb39c9cc86..60ea31945f 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index fc6a72814e..30c6c7ad57 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index c64fbf6637..c49bfcb815 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 00951b5098..345adbbc54 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index 459665143a..9b075a8981 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 93b3b8fbae..0df197ddc9 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index bca62c3754..44ca9e5b63 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index 12de624f30..af80f2ca76 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 9b12f7d29d..ddd3a4caca 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 87ffbe24de..0165fc3db1 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2023-02-09 19:50 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2023-02-09 19:50 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4bdb85e3ec5fb34db6f1f4d4928e1440df72ce54

commit 4bdb85e3ec5fb34db6f1f4d4928e1440df72ce54
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 91 insertions(+), 81 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 420930d558..884b30171a 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index 33acadeeaa..cafa643834 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index 030a9d0a9c..746e24f33a 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 531ca0104f..70d616dd82 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index 654441ee30..0dc5db40d9 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index fdc68cc483..9b2ea73d63 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 271941bb8e..743ae66280 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index 704ec88a6e..10fdb8e0f0 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index c37a3ff637..e8ea1ddfb0 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -704,4 +704,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 493091ccd4..d16f1e7c83 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index 5a3a131002..c9917a29fc 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index eabf3f3391..b5fbfc033e 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index e7cd0e3102..0b6e1d7343 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index d6b3df0762..e5a8cb9c2e 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index c80cb7c352..d0c05fda14 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 77f73e10ae..c7a6dff329 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 06230377cd..535c31948b 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 6546a27fad..93cf1fb213 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 39a47365cd..99258332ef 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 03e3c94d8a..89b9a63159 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 4e8ba30373..abcaf43bd3 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 9926fefa8c..67c4d9cac0 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index f3a83b86a6..daa39026dc 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index e6de5e71b9..0e3a5fe1a6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 3ec7343ebe..d541630b31 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index cb39c9cc86..60ea31945f 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index fc6a72814e..30c6c7ad57 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index c64fbf6637..c49bfcb815 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 00951b5098..345adbbc54 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index 459665143a..9b075a8981 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 93b3b8fbae..0df197ddc9 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index bca62c3754..44ca9e5b63 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index 12de624f30..af80f2ca76 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index 9b12f7d29d..ddd3a4caca 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 87ffbe24de..0165fc3db1 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-10-28 17:43 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-10-28 17:43 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=81a1b4bebaa599b09a6d5c78b451d3fe290988dc

commit 81a1b4bebaa599b09a6d5c78b451d3fe290988dc
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 91 insertions(+), 81 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index aeb882d442..2567028efc 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index f525f67547..9e34b3d42b 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -702,4 +702,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index 371916a2f0..bb853a13c2 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index 2d27b20a68..efa7bf3d4c 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-10-04 13:01 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-10-04 13:01 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f9d9cd20bba5024d83f1caa3ca8be410f70226f8

commit f9d9cd20bba5024d83f1caa3ca8be410f70226f8
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 91 insertions(+), 81 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index f525f67547..9e34b3d42b 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -702,4 +702,11 @@ _Static_assert (0, "IEEE 128-bits long double requires redirection on this platf
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcmp-rtm.c b/sysdeps/x86/tst-strcmp-rtm.c
index 371916a2f0..bb853a13c2 100644
--- a/sysdeps/x86/tst-strcmp-rtm.c
+++ b/sysdeps/x86/tst-strcmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index 2d27b20a68..efa7bf3d4c 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -40,7 +40,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -52,7 +52,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -62,7 +62,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-06-09 21:22 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 21:22 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=89204b79cc1c8f2bb9782ee2288344035c19bca7

commit 89204b79cc1c8f2bb9782ee2288344035c19bca7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 35a54b694a..536b825a03 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-06-09 13:18 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 13:18 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=89204b79cc1c8f2bb9782ee2288344035c19bca7

commit 89204b79cc1c8f2bb9782ee2288344035c19bca7
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 35a54b694a..536b825a03 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-05-13 14:21 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-05-13 14:21 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=53e3f75eaba713282c74c443ec678516a4981ddc

commit 53e3f75eaba713282c74c443ec678516a4981ddc
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 2138312344..329b7492e9 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-05-12 19:35 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 19:35 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e6fa48cea10bd38c799f0700021265fad473437b

commit e6fa48cea10bd38c799f0700021265fad473437b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 2138312344..329b7492e9 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-05-10 18:26 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-05-10 18:26 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c9384a7a6bc6eb2e590a3edbfe09c1f42edd9435

commit c9384a7a6bc6eb2e590a3edbfe09c1f42edd9435
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 2138312344..329b7492e9 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-04-29 14:06 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-04-29 14:06 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=02252c39e15c8ede6fcf49b20cba852fc2465639

commit 02252c39e15c8ede6fcf49b20cba852fc2465639
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 2138312344..329b7492e9 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-04-04 12:56 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-04-04 12:56 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d87006af4a1a3d88c16df4870a11a03abf977ec0

commit d87006af4a1a3d88c16df4870a11a03abf977ec0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 benchtests/bench-strchr.c               |  4 ++--
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 35 files changed, 90 insertions(+), 80 deletions(-)

diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 54640bde7e..54c5c283ae 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -93,7 +93,7 @@ IMPL (STRCHR, 1)
    branch coming we want to test the case where a potential branch in
    strchr can be used to skip a later mispredict because of the
    relationship between the two branches. */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
@@ -118,7 +118,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
   json_element_double (json_ctx, (double)cur / (double)iters);
 }
 
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
                   const CHAR *c)
 {
diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 090aad6fed..e9acdbd723 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-03-31 19:08 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-03-31 19:08 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3f02958260e9e0587470102645c48ba77934c2ee

commit 3f02958260e9e0587470102645c48ba77934c2ee
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 34 files changed, 88 insertions(+), 78 deletions(-)

diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 090aad6fed..e9acdbd723 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 67e696b562..0753859110 100644
--- a/nptl/tst-thread_local1.cc
+++ b/nptl/tst-thread_local1.cc
@@ -53,27 +53,27 @@ to_string (const counter &c)
 template <counter *Counter>
 struct counting
 {
-  counting () __attribute__ ((noinline, noclone));
-  ~counting () __attribute__ ((noinline, noclone));
-  void operation () __attribute__ ((noinline, noclone));
+  counting () __attribute__ ((noinline)) __attribute_noclone__;
+  ~counting () __attribute__ ((noinline)) __attribute_noclone__;
+  void operation () __attribute__ ((noinline)) __attribute_noclone__;
 };
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::counting ()
 {
   ++Counter->constructed;
 }
 
 template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::~counting ()
 {
   ++Counter->destructed;
 }
 
 template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute__ ((noinline)) __attribute_noclone__
 counting<Counter>::operation ()
 {
   // Optimization barrier.
diff --git a/stdlib/tst-makecontext-align.c b/stdlib/tst-makecontext-align.c
index bb3fec155a..1ec4594aad 100644
--- a/stdlib/tst-makecontext-align.c
+++ b/stdlib/tst-makecontext-align.c
@@ -30,7 +30,7 @@ static const char *context;
 
 /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align (void *address, size_t alignment)
 {
@@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
 
 /* Various alignment checking functions.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_int (void)
 {
@@ -53,7 +53,7 @@ check_align_int (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long (void)
 {
@@ -61,7 +61,7 @@ check_align_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_long_long (void)
 {
@@ -69,7 +69,7 @@ check_align_long_long (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_double (void)
 {
@@ -77,7 +77,7 @@ check_align_double (void)
   check_align (&a, __alignof__ (a));
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_4 (void)
 {
@@ -85,7 +85,7 @@ check_align_4 (void)
   check_align (&a, 4);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_8 (void)
 {
@@ -93,7 +93,7 @@ check_align_8 (void)
   check_align (&a, 8);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_16 (void)
 {
@@ -105,7 +105,7 @@ check_align_16 (void)
   check_align (&a, 16);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_align_32 (void)
 {
@@ -120,7 +120,7 @@ check_align_32 (void)
 }
 
 /* Call all the alignment checking functions.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_alignments (void)
 {
diff --git a/stdlib/tst-quick_exit.cc b/stdlib/tst-quick_exit.cc
index d59b6825d6..acc9dfd7ad 100644
--- a/stdlib/tst-quick_exit.cc
+++ b/stdlib/tst-quick_exit.cc
@@ -26,7 +26,7 @@ struct A
 thread_local A a;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/stdlib/tst-setcontext5.c b/stdlib/tst-setcontext5.c
index 64f81a30a6..0a59df7187 100644
--- a/stdlib/tst-setcontext5.c
+++ b/stdlib/tst-setcontext5.c
@@ -27,7 +27,7 @@ static volatile int done;
 static void f2 (void);
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f1 (void)
 {
   printf ("start f1\n");
@@ -35,7 +35,7 @@ f1 (void)
 }
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext8.c b/stdlib/tst-setcontext8.c
index 82d5e89e9d..9046737d35 100644
--- a/stdlib/tst-setcontext8.c
+++ b/stdlib/tst-setcontext8.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[3];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   printf ("start f2\n");
diff --git a/stdlib/tst-setcontext9.c b/stdlib/tst-setcontext9.c
index 23cf09d1e2..a05f0ffdb5 100644
--- a/stdlib/tst-setcontext9.c
+++ b/stdlib/tst-setcontext9.c
@@ -26,7 +26,7 @@ static ucontext_t ctx[5];
 static atomic_int done;
 
 static void
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 f2 (void)
 {
   done++;
diff --git a/stdlib/tst-swapcontext1.c b/stdlib/tst-swapcontext1.c
index 8850279ec3..a4170ae18c 100644
--- a/stdlib/tst-swapcontext1.c
+++ b/stdlib/tst-swapcontext1.c
@@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
 #define handle_error(msg) \
   do { perror(msg); exit(EXIT_FAILURE); } while (0)
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -39,7 +39,7 @@ func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("      %sfunc4: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
 {
@@ -48,7 +48,7 @@ func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt)
   printf("    %sfunc3: returning\e[0m\n", fmt);
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func1(void)
 {
@@ -59,7 +59,7 @@ func1(void)
     }
 }
 
-__attribute__((noinline, noclone))
+__attribute__((noinline)) __attribute_noclone__
 static void
 func2(void)
 {
diff --git a/stdlib/tst-thread-quick_exit.cc b/stdlib/tst-thread-quick_exit.cc
index 706d7b23d5..9e4ba0e2bf 100644
--- a/stdlib/tst-thread-quick_exit.cc
+++ b/stdlib/tst-thread-quick_exit.cc
@@ -30,7 +30,7 @@ thread_local A a1;
 thread_local A a2;
 
 void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 optimization_barrier (A &)
 {
 }
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index 64993d7a47..c6fefd3a5f 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,7 +97,8 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
-static __attribute__ ((noinline, noclone)) int
+static __attribute__ ((noinline)) __attribute_noclone__
+int
 use_test_buffer (unsigned char *buf)
 {
   unsigned int sum = 0;
diff --git a/sysdeps/generic/tst-stack-align.h b/sysdeps/generic/tst-stack-align.h
index 91a5cd7228..96f309eed5 100644
--- a/sysdeps/generic/tst-stack-align.h
+++ b/sysdeps/generic/tst-stack-align.h
@@ -20,7 +20,7 @@
 #include <stdint.h>
 
 int
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) != 0;
diff --git a/sysdeps/x86/tst-ldbl-nonnormal-printf.c b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
index 9dae2e4c9b..63dd1be46b 100644
--- a/sysdeps/x86/tst-ldbl-nonnormal-printf.c
+++ b/sysdeps/x86/tst-ldbl-nonnormal-printf.c
@@ -23,7 +23,7 @@
 
 /* Fill the stack with non-zero values.  This makes a crash in
    snprintf more likely.  */
-static void __attribute__ ((noinline, noclone))
+static void __attribute__ ((noinline)) __attribute_noclone__
 fill_stack (void)
 {
   char buffer[65536];
diff --git a/sysdeps/x86/tst-memchr-rtm.c b/sysdeps/x86/tst-memchr-rtm.c
index 117757e412..5b7bf7bcc6 100644
--- a/sysdeps/x86/tst-memchr-rtm.c
+++ b/sysdeps/x86/tst-memchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memcmp-rtm.c b/sysdeps/x86/tst-memcmp-rtm.c
index 98a86f1288..294d55bec6 100644
--- a/sysdeps/x86/tst-memcmp-rtm.c
+++ b/sysdeps/x86/tst-memcmp-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memmove-rtm.c b/sysdeps/x86/tst-memmove-rtm.c
index 0f5341f083..639b1b9faa 100644
--- a/sysdeps/x86/tst-memmove-rtm.c
+++ b/sysdeps/x86/tst-memmove-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memrchr-rtm.c b/sysdeps/x86/tst-memrchr-rtm.c
index 34d54a5138..07ffd1ac42 100644
--- a/sysdeps/x86/tst-memrchr-rtm.c
+++ b/sysdeps/x86/tst-memrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-memset-rtm.c b/sysdeps/x86/tst-memset-rtm.c
index 89e0a2119e..06bc7963f1 100644
--- a/sysdeps/x86/tst-memset-rtm.c
+++ b/sysdeps/x86/tst-memset-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -30,7 +30,7 @@ prepare (void)
   return EXIT_SUCCESS;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strchr-rtm.c b/sysdeps/x86/tst-strchr-rtm.c
index 22f0ba9a89..24e159e6da 100644
--- a/sysdeps/x86/tst-strchr-rtm.c
+++ b/sysdeps/x86/tst-strchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -36,7 +36,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strcpy-rtm.c b/sysdeps/x86/tst-strcpy-rtm.c
index 051555cf52..beaf5c5add 100644
--- a/sysdeps/x86/tst-strcpy-rtm.c
+++ b/sysdeps/x86/tst-strcpy-rtm.c
@@ -23,7 +23,7 @@
 char string1[STRING_SIZE];
 char string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strlen-rtm.c b/sysdeps/x86/tst-strlen-rtm.c
index 51a5c5692e..7b840b2de5 100644
--- a/sysdeps/x86/tst-strlen-rtm.c
+++ b/sysdeps/x86/tst-strlen-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86/tst-strncmp-rtm.c b/sysdeps/x86/tst-strncmp-rtm.c
index a3b14e72ff..fc33e9229a 100644
--- a/sysdeps/x86/tst-strncmp-rtm.c
+++ b/sysdeps/x86/tst-strncmp-rtm.c
@@ -38,7 +38,7 @@
 CHAR string1[STRING_SIZE];
 CHAR string2[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -50,7 +50,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
@@ -60,7 +60,7 @@ function (void)
     return 1;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function_overflow (void)
 {
diff --git a/sysdeps/x86/tst-strrchr-rtm.c b/sysdeps/x86/tst-strrchr-rtm.c
index fd5c944eeb..c2aeb2067e 100644
--- a/sysdeps/x86/tst-strrchr-rtm.c
+++ b/sysdeps/x86/tst-strrchr-rtm.c
@@ -22,7 +22,7 @@
 #define STRING_SIZE 1024
 char string1[STRING_SIZE];
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 prepare (void)
 {
@@ -35,7 +35,7 @@ prepare (void)
     return EXIT_FAILURE;
 }
 
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static int
 function (void)
 {
diff --git a/sysdeps/x86_64/tst-rsi-strlen.c b/sysdeps/x86_64/tst-rsi-strlen.c
index 0bd82c2aad..682172f6e3 100644
--- a/sysdeps/x86_64/tst-rsi-strlen.c
+++ b/sysdeps/x86_64/tst-rsi-strlen.c
@@ -44,7 +44,7 @@ typedef struct
 } parameter_t;
 
 size_t
-__attribute__ ((weak, noinline, noclone))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 do_strlen (parameter_t *a, int zero, const CHAR *str)
 {
   return CALL (a, str);


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [glibc/azanella/clang] And defines to __attribute__ (__noclone__) iff compiler supports it.
@ 2022-03-29 20:31 Adhemerval Zanella
  0 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2022-03-29 20:31 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d3df9dfc1da9f468d4cc5e8e6e31cb211f01b80d

commit d3df9dfc1da9f468d4cc5e8e6e31cb211f01b80d
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 24 15:02:20 2022 -0300

    And defines to __attribute__ (__noclone__) iff compiler supports it.

Diff:
---
 debug/tst-backtrace.h                   |  2 +-
 debug/tst-ssp-1.c                       |  2 +-
 elf/tst-dlmodcount.c                    |  2 +-
 elf/tst-p_alignmod-base.c               |  2 +-
 gmon/tst-gmon.c                         |  8 +++++---
 malloc/tst-malloc-thread-exit.c         |  2 +-
 malloc/tst-malloc-thread-fail.c         |  2 +-
 malloc/tst-mallocstate.c                |  2 +-
 misc/sys/cdefs.h                        |  7 +++++++
 misc/tst-syscalls.c                     | 14 +++++++-------
 nptl/tst-minstack-throw.cc              |  8 ++++----
 nptl/tst-thread-exit-clobber.cc         | 12 ++++++------
 nptl/tst-thread_local1.cc               | 12 ++++++------
 stdlib/tst-makecontext-align.c          | 20 ++++++++++----------
 stdlib/tst-quick_exit.cc                |  2 +-
 stdlib/tst-setcontext5.c                |  4 ++--
 stdlib/tst-setcontext8.c                |  2 +-
 stdlib/tst-setcontext9.c                |  2 +-
 stdlib/tst-swapcontext1.c               |  8 ++++----
 stdlib/tst-thread-quick_exit.cc         |  2 +-
 string/tst-xbzero-opt.c                 |  3 ++-
 sysdeps/generic/tst-stack-align.h       |  2 +-
 sysdeps/x86/tst-ldbl-nonnormal-printf.c |  2 +-
 sysdeps/x86/tst-memchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-memcmp-rtm.c            |  4 ++--
 sysdeps/x86/tst-memmove-rtm.c           |  4 ++--
 sysdeps/x86/tst-memrchr-rtm.c           |  4 ++--
 sysdeps/x86/tst-memset-rtm.c            |  4 ++--
 sysdeps/x86/tst-strchr-rtm.c            |  4 ++--
 sysdeps/x86/tst-strcpy-rtm.c            |  4 ++--
 sysdeps/x86/tst-strlen-rtm.c            |  4 ++--
 sysdeps/x86/tst-strncmp-rtm.c           |  6 +++---
 sysdeps/x86/tst-strrchr-rtm.c           |  4 ++--
 sysdeps/x86_64/tst-rsi-strlen.c         |  2 +-
 34 files changed, 88 insertions(+), 78 deletions(-)

diff --git a/debug/tst-backtrace.h b/debug/tst-backtrace.h
index f79b267fce..6c86005f2e 100644
--- a/debug/tst-backtrace.h
+++ b/debug/tst-backtrace.h
@@ -33,7 +33,7 @@ volatile int x;
 
 /* Use this attribute to prevent inlining, so that all expected frames
    are present.  */
-#define NO_INLINE __attribute__ ((noinline, noclone, weak))
+#define NO_INLINE __attribute__ ((noinline, weak)) __attribute_noclone__
 
 /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
    of a function name.  Ignore the filename before '(', but presume
diff --git a/debug/tst-ssp-1.c b/debug/tst-ssp-1.c
index c2d1baa99c..74a4403f18 100644
--- a/debug/tst-ssp-1.c
+++ b/debug/tst-ssp-1.c
@@ -21,7 +21,7 @@
 #include <signal.h>
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 test (char *foo)
 {
   int i;
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 8a96803d85..d5f89b8f79 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -32,7 +32,7 @@ callback (struct dl_phdr_info *info, size_t size, void *ptr)
   static int last_adds = 0, last_subs = 0;
   intptr_t cmd = (intptr_t) ptr;
 
-  printf ("  size = %Zu\n", size);
+  printf ("  size = %zu\n", size);
   if (size < (offsetof (struct dl_phdr_info, dlpi_subs)
 	      + sizeof (info->dlpi_subs)))
     {
diff --git a/elf/tst-p_alignmod-base.c b/elf/tst-p_alignmod-base.c
index 0fc1b75523..4aae5f1e54 100644
--- a/elf/tst-p_alignmod-base.c
+++ b/elf/tst-p_alignmod-base.c
@@ -26,7 +26,7 @@
 int foo __attribute__ ((aligned (ALIGN))) = 1;
 
 bool
-__attribute__ ((weak, noclone, noinline))
+__attribute__ ((weak, noinline)) __attribute_noclone__
 is_aligned_p (void *p, int align)
 {
   return (((uintptr_t) p) & (align - 1)) == 0;
diff --git a/gmon/tst-gmon.c b/gmon/tst-gmon.c
index aca5921523..72a80a629f 100644
--- a/gmon/tst-gmon.c
+++ b/gmon/tst-gmon.c
@@ -16,15 +16,17 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <sys/cdefs.h>
+
 /* This program does not use the test harness because we want tight
    control over the call graph.  */
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f1 (void)
 {
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f2 (void)
 {
   f1 ();
@@ -32,7 +34,7 @@ f2 (void)
   asm volatile ("");
 }
 
-__attribute__ ((noinline, noclone, weak)) void
+__attribute__ ((noinline, weak)) __attribute_noclone__ void
 f3 (int count)
 {
   for (int i = 0; i < count; ++i)
diff --git a/malloc/tst-malloc-thread-exit.c b/malloc/tst-malloc-thread-exit.c
index 492d969686..41d73d6653 100644
--- a/malloc/tst-malloc-thread-exit.c
+++ b/malloc/tst-malloc-thread-exit.c
@@ -42,7 +42,7 @@ static int inner_thread_count = 4;
 static size_t malloc_size = 32;
 
 static void
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 unoptimized_free (void *ptr)
 {
   free (ptr);
diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c
index 65cf9321c2..074ac5332f 100644
--- a/malloc/tst-malloc-thread-fail.c
+++ b/malloc/tst-malloc-thread-fail.c
@@ -33,7 +33,7 @@
 
 /* Wrapper for calloc with an optimization barrier.  */
 static void *
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 allocate_zeroed (size_t a, size_t b)
 {
   return calloc (a, b);
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
index c2011a44ef..9d658fd85d 100644
--- a/malloc/tst-mallocstate.c
+++ b/malloc/tst-mallocstate.c
@@ -366,7 +366,7 @@ full_heap_check (void)
 }
 
 /* Used as an optimization barrier to force a heap allocation.  */
-__attribute__ ((noinline, noclone))
+__attribute__ ((noinline)) __attribute_noclone__
 static void
 my_free (void *ptr)
 {
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 090aad6fed..e9acdbd723 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -703,4 +703,11 @@ _Static_assert (0, "Compat long double requires redirection on this platform");
 # define __attribute_returns_twice__ /* Ignore.  */
 #endif
 
+/*  Prevents a function from being considered for cloning.  */
+#if __GNUC_PREREQ (4, 5) || __glibc_has_attribute (__noclone__)
+# define __attribute_noclone__ __attribute__ ((__noclone__))
+#else
+# define __attribute_noclone__ /* Ignore.  */
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/misc/tst-syscalls.c b/misc/tst-syscalls.c
index 09b5128e8b..08b0cd2e56 100644
--- a/misc/tst-syscalls.c
+++ b/misc/tst-syscalls.c
@@ -37,7 +37,7 @@ struct Array
 
 static int error_count;
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 struct Array
 allocate (size_t bytes)
 {
@@ -52,7 +52,7 @@ allocate (size_t bytes)
   return __extension__ (struct Array) {bytes, p};
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 deallocate (struct Array b)
 {
@@ -66,7 +66,7 @@ deallocate (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 do_mmap (void *addr, size_t length)
 {
@@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
 	       MAP_PRIVATE | MAP_ANON, -1, 0);
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void *
 reallocate (struct Array b)
 {
@@ -86,7 +86,7 @@ reallocate (struct Array b)
   return NULL;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 void
 protect (struct Array b)
 {
@@ -104,7 +104,7 @@ protect (struct Array b)
     }
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_read (int fd, void *ptr, struct Array b)
 {
@@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
   return 0;
 }
 
-__attribute__ ((noclone, noinline))
+__attribute__ ((noinline)) __attribute_noclone__
 ssize_t
 do_write (int fd, void *ptr, struct Array b)
 {
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index d2f020a93a..4c69289c66 100644
--- a/nptl/tst-minstack-throw.cc
+++ b/nptl/tst-minstack-throw.cc
@@ -24,7 +24,7 @@
 #include <support/xthread.h>
 
 /* Throw a std::runtime_exception.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 do_throw_exception ()
 {
@@ -38,17 +38,17 @@ struct class_with_destructor
   ~class_with_destructor ();
 };
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 class_with_destructor::~class_with_destructor ()
 {
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 function_with_destructed_object ()
 {
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index f9f4e1fc80..88f2451fdb 100644
--- a/nptl/tst-thread-exit-clobber.cc
+++ b/nptl/tst-thread-exit-clobber.cc
@@ -73,7 +73,7 @@ enum { no_check = -1 };
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, unsigned int value)
 {
@@ -103,7 +103,7 @@ check_magic (int index, unsigned int value)
 
 /* Check that VALUE is the magic value for INDEX, behind a compiler
    barrier.  Double variant.  */
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 check_magic (int index, double value)
 {
@@ -153,7 +153,7 @@ struct checker
    call_pthread_exit are used to call pthread_exit indirectly, with
    the intent of clobbering the register values.  */
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_0 (const values<unsigned int> *pvalues)
 {
@@ -166,7 +166,7 @@ call_pthread_exit_0 (const values<unsigned int> *pvalues)
   pthread_exit (NULL);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit_1 (const values<double> *pvalues)
 {
@@ -180,7 +180,7 @@ call_pthread_exit_1 (const values<double> *pvalues)
   call_pthread_exit_0 (&other_values);
 }
 
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void
 call_pthread_exit ()
 {
@@ -192,7 +192,7 @@ call_pthread_exit ()
    pthread_exit.  If Nested is true, call pthread_exit indirectly via
    call_pthread_exit.  */
 template <class T, bool Nested>
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((noinline, weak)) __attribute_noclone__
 void *
 threadfunc (void *closure)
 {