aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-12-23 05:11:58 +0800
committerH.J. Lu <hjl.tools@gmail.com>2024-12-23 06:28:55 +0800
commita2b0ff98a0d44259cc5f6bd7d3a3676ae9f8996a (patch)
tree7816983cdeea6e6c32dd005c76da785811ea3047 /nptl
parent3fb895ac88e99201573352b1abc18db4340ecede (diff)
downloadglibc-a2b0ff98a0d44259cc5f6bd7d3a3676ae9f8996a.tar.xz
glibc-a2b0ff98a0d44259cc5f6bd7d3a3676ae9f8996a.zip
include/sys/cdefs.h: Add __attribute_optimization_barrier__
Add __attribute_optimization_barrier__ to disable inlining and cloning on a function. For Clang, expand it to __attribute__ ((optnone)) Otherwise, expand it to __attribute__ ((noinline, clone)) Co-Authored-By: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'nptl')
-rw-r--r--nptl/tst-minstack-throw.cc8
-rw-r--r--nptl/tst-thread-exit-clobber.cc12
-rw-r--r--nptl/tst-thread_local1.cc12
3 files changed, 16 insertions, 16 deletions
diff --git a/nptl/tst-minstack-throw.cc b/nptl/tst-minstack-throw.cc
index b729091ec4..ff0d3d39da 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__ ((weak)) __attribute_optimization_barrier__
void
do_throw_exception ()
{
@@ -38,17 +38,17 @@ struct class_with_destructor
~class_with_destructor ();
};
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((weak)) __attribute_optimization_barrier__
class_with_destructor::class_with_destructor ()
{
}
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((weak)) __attribute_optimization_barrier__
class_with_destructor::~class_with_destructor ()
{
}
-__attribute__ ((noinline, noclone, weak))
+__attribute__ ((weak)) __attribute_optimization_barrier__
void
function_with_destructed_object ()
{
diff --git a/nptl/tst-thread-exit-clobber.cc b/nptl/tst-thread-exit-clobber.cc
index b3b6989268..9a50848ef8 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__ ((weak)) __attribute_optimization_barrier__
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__ ((weak)) __attribute_optimization_barrier__
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__ ((weak)) __attribute_optimization_barrier__
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__ ((weak)) __attribute_optimization_barrier__
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__ ((weak)) __attribute_optimization_barrier__
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__ ((weak)) __attribute_optimization_barrier__
void *
threadfunc (void *closure)
{
diff --git a/nptl/tst-thread_local1.cc b/nptl/tst-thread_local1.cc
index 270520528c..d78ad2731c 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_optimization_barrier__;
+ ~counting () __attribute_optimization_barrier__;
+ void operation () __attribute_optimization_barrier__;
};
template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute_optimization_barrier__
counting<Counter>::counting ()
{
++Counter->constructed;
}
template<counter *Counter>
-__attribute__ ((noinline, noclone))
+__attribute_optimization_barrier__
counting<Counter>::~counting ()
{
++Counter->destructed;
}
template<counter *Counter>
-void __attribute__ ((noinline, noclone))
+void __attribute_optimization_barrier__
counting<Counter>::operation ()
{
// Optimization barrier.