[PATCH] Use __attribute_optimization_barrier__ for the remaining noclone users

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Aug 21 15:45:19 GMT 2026



On 21/08/26 01:22, Matt Turner wrote:
> Commit a2b0ff98a0 added __attribute_optimization_barrier__ and converted the
> users of __attribute__ ((noinline, noclone)) to it, so that Clang, which does
> not implement noclone, gets optnone instead of an unknown-attribute warning
> that is an error under -Werror.
> 
> Twelve users were missed, all of them in code that a plain x86_64 build never
> preprocesses, which is why they survived the sweep:
> 
>   - libio/tst-stderr-compat.c is inside
>     #if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_1), so it is compiled only on
>     ports that still have GLIBC_2.0 compat symbols -- i686 and alpha among
>     them, but not x86_64.  Building it with Clang fails.
> 
>   - The eleven sysdeps/x86_64/x32/tst-size_t-*.c tests are built only for the
>     x32 ABI.
> 
> No functional change for GCC, which still gets noinline and noclone.
> 
> Checked that both shapes -- the weak function in libio and the static function
> in the x32 tests -- compile with GCC and with Clang after the change, and that
> the pre-change shape is an error under Clang with -Werror.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  libio/tst-stderr-compat.c                   | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-memchr.c      | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-memcmp-2.c    | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-memcmp.c      | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-memcpy.c      | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-memrchr.c     | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-memset.c      | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-strncasecmp.c | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-strncat.c     | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-strncmp.c     | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-strncpy.c     | 2 +-
>  sysdeps/x86_64/x32/tst-size_t-strnlen.c     | 2 +-
>  12 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git ./libio/tst-stderr-compat.c ./libio/tst-stderr-compat.c
> index 924b046dfa..9e0a2cd739 100644
> --- ./libio/tst-stderr-compat.c
> +++ ./libio/tst-stderr-compat.c
> @@ -28,7 +28,7 @@ extern FILE _IO_stderr_;
>  compat_symbol_reference (libc, _IO_stderr_, _IO_stderr_, GLIBC_2_0);
>  compat_symbol_reference (libc, fclose, fclose, GLIBC_2_0);
>  
> -__attribute__ ((weak, noclone, noinline))
> +__attribute__ ((weak)) __attribute_optimization_barrier__
>  void
>  do_fclose (FILE *fp)
>  {
> diff --git ./sysdeps/x86_64/x32/tst-size_t-memchr.c ./sysdeps/x86_64/x32/tst-size_t-memchr.c
> index faf5d68584..b1bbf7ef14 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-memchr.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-memchr.c
> @@ -39,7 +39,7 @@ IMPL (MEMCHR, 1)
>  typedef CHAR * (*proto_t) (const CHAR*, int, size_t);
>  
>  static CHAR *
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_memchr (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, (uintptr_t) b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-memcmp-2.c ./sysdeps/x86_64/x32/tst-size_t-memcmp-2.c
> index 5e84ee6702..0e28f93c43 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-memcmp-2.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-memcmp-2.c
> @@ -41,7 +41,7 @@ IMPL (MEMCMP, 1)
>  typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
>  
>  static int
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_memcmp (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-memcmp.c ./sysdeps/x86_64/x32/tst-size_t-memcmp.c
> index 75d631bd77..6b487ddf6c 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-memcmp.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-memcmp.c
> @@ -41,7 +41,7 @@ IMPL (MEMCMP, 1)
>  typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
>  
>  static int
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_memcmp (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-memcpy.c ./sysdeps/x86_64/x32/tst-size_t-memcpy.c
> index 34e7da413e..5847a62fa4 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-memcpy.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-memcpy.c
> @@ -24,7 +24,7 @@ IMPL (memcpy, 1)
>  typedef void *(*proto_t) (void *, const void *, size_t);
>  
>  static void *
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_memcpy (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-memrchr.c ./sysdeps/x86_64/x32/tst-size_t-memrchr.c
> index ad881b3cff..a215f3389f 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-memrchr.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-memrchr.c
> @@ -24,7 +24,7 @@ IMPL (memchr, 1)
>  typedef void * (*proto_t) (const void *, int, size_t);
>  
>  static void *
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_memrchr (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, (uintptr_t) b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-memset.c ./sysdeps/x86_64/x32/tst-size_t-memset.c
> index 70eaa473af..61bbc2e2d0 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-memset.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-memset.c
> @@ -38,7 +38,7 @@ IMPL (MEMSET, 1)
>  typedef CHAR *(*proto_t) (CHAR *, int, size_t);
>  
>  static void *
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_memset (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, (uintptr_t) b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-strncasecmp.c ./sysdeps/x86_64/x32/tst-size_t-strncasecmp.c
> index fb99db93a2..d0ad1eb863 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-strncasecmp.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-strncasecmp.c
> @@ -24,7 +24,7 @@ IMPL (strncasecmp, 1)
>  typedef int (*proto_t) (const char *, const char *, size_t);
>  
>  static int
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_strncasecmp (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-strncat.c ./sysdeps/x86_64/x32/tst-size_t-strncat.c
> index 2376ff59f2..08c86cc248 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-strncat.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-strncat.c
> @@ -24,7 +24,7 @@ IMPL (strncat, 1)
>  typedef char *(*proto_t) (char *, const char*, size_t);
>  
>  static void *
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_strncat (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-strncmp.c ./sysdeps/x86_64/x32/tst-size_t-strncmp.c
> index 4d14de54e9..ff12d5e81b 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-strncmp.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-strncmp.c
> @@ -42,7 +42,7 @@ typedef int (*proto_t) (const CHAR *, const CHAR *, size_t);
>  
>  
>  static int
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_strncmp (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-strncpy.c ./sysdeps/x86_64/x32/tst-size_t-strncpy.c
> index aef196eac1..7fb19d59ab 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-strncpy.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-strncpy.c
> @@ -24,7 +24,7 @@ IMPL (strncpy, 1)
>  typedef char *(*proto_t) (char *, const char*, size_t);
>  
>  static void *
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_strncpy (parameter_t a, parameter_t b)
>  {
>    return CALL (&b, a.p, b.p, a.len);
> diff --git ./sysdeps/x86_64/x32/tst-size_t-strnlen.c ./sysdeps/x86_64/x32/tst-size_t-strnlen.c
> index d7299a9b35..b289a47b50 100644
> --- ./sysdeps/x86_64/x32/tst-size_t-strnlen.c
> +++ ./sysdeps/x86_64/x32/tst-size_t-strnlen.c
> @@ -38,7 +38,7 @@ IMPL (STRNLEN, 1)
>  typedef size_t (*proto_t) (const CHAR *, size_t);
>  
>  static size_t
> -__attribute__ ((noinline, noclone))
> +__attribute_optimization_barrier__
>  do_strnlen (parameter_t a, parameter_t b)
>  {
>    return CALL (&a, a.p, b.len);



More information about the Libc-alpha mailing list