From a2b0ff98a0d44259cc5f6bd7d3a3676ae9f8996a Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 23 Dec 2024 05:11:58 +0800 Subject: 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 Reviewed-by: Sam James --- nptl/tst-minstack-throw.cc | 8 ++++---- nptl/tst-thread-exit-clobber.cc | 12 ++++++------ nptl/tst-thread_local1.cc | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'nptl') 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 /* 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 *pvalues) { @@ -166,7 +166,7 @@ call_pthread_exit_0 (const values *pvalues) pthread_exit (NULL); } -__attribute__ ((noinline, noclone, weak)) +__attribute__ ((weak)) __attribute_optimization_barrier__ void call_pthread_exit_1 (const values *pvalues) { @@ -180,7 +180,7 @@ call_pthread_exit_1 (const values *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 -__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 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 -__attribute__ ((noinline, noclone)) +__attribute_optimization_barrier__ counting::counting () { ++Counter->constructed; } template -__attribute__ ((noinline, noclone)) +__attribute_optimization_barrier__ counting::~counting () { ++Counter->destructed; } template -void __attribute__ ((noinline, noclone)) +void __attribute_optimization_barrier__ counting::operation () { // Optimization barrier. -- cgit v1.2.3