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>
This commit is contained in:
Adhemerval Zanella 2024-12-23 05:11:58 +08:00 committed by H.J. Lu
parent 3fb895ac88
commit a2b0ff98a0
45 changed files with 112 additions and 101 deletions

View file

@ -35,7 +35,7 @@
#define PRIMITIVE_CAT(x, y) x ## y #define PRIMITIVE_CAT(x, y) x ## y
#define CAT(x, y) PRIMITIVE_CAT (x, y) #define CAT(x, y) PRIMITIVE_CAT (x, y)
static double __attribute__ ((noinline, noclone)) static double __attribute_optimization_barrier__
CAT (do_one_test_kernel, POSTFIX) (const char *s, size_t len) 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; return (double) cur / (double) NFIXED_ITERS;
} }
static double __attribute__ ((noinline, noclone)) static double __attribute_optimization_barrier__
CAT (do_rand_test_kernel, POSTFIX) (char const *bufs, CAT (do_rand_test_kernel, POSTFIX) (char const *bufs,
unsigned int const *sizes) unsigned int const *sizes)
{ {

View file

@ -67,7 +67,7 @@ do_one_test (json_ctx_t *json_ctx, size_t len)
json_element_object_end (json_ctx); json_element_object_end (json_ctx);
} }
static void __attribute__ ((noinline, noclone)) static void __attribute_optimization_barrier__
do_rand_test (json_ctx_t *json_ctx) do_rand_test (json_ctx_t *json_ctx)
{ {
size_t i, sz, offset; size_t i, sz, offset;

View file

@ -92,7 +92,7 @@ IMPL (generic_strchrnul, 0)
branch coming we want to test the case where a potential branch in 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 strchr can be used to skip a later mispredict because of the
relationship between the two branches. */ relationship between the two branches. */
static void __attribute__ ((noinline, noclone)) static void __attribute_optimization_barrier__
do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl, do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
const CHAR *s, const CHAR *c) 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); json_element_double (json_ctx, (double)cur / (double)iters);
} }
static void __attribute__ ((noinline, noclone)) static void __attribute_optimization_barrier__
do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, do_one_rand_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s,
const CHAR *c) const CHAR *c)
{ {

View file

@ -33,7 +33,7 @@ volatile int x;
/* Use this attribute to prevent inlining, so that all expected frames /* Use this attribute to prevent inlining, so that all expected frames
are present. */ are present. */
#define NO_INLINE __attribute__ ((noinline, noclone, weak)) #define NO_INLINE __attribute__ ((weak)) __attribute_optimization_barrier__
/* Look for a match in SYM from backtrace_symbols to NAME, a fragment /* Look for a match in SYM from backtrace_symbols to NAME, a fragment
of a function name. Ignore the filename before '(', but presume of a function name. Ignore the filename before '(', but presume

View file

@ -21,7 +21,7 @@
#include <signal.h> #include <signal.h>
static void static void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
test (char *foo) test (char *foo)
{ {
int i; int i;

View file

@ -26,7 +26,7 @@
int foo __attribute__ ((aligned (ALIGN))) = 1; int foo __attribute__ ((aligned (ALIGN))) = 1;
bool bool
__attribute__ ((weak, noclone, noinline)) __attribute__ ((weak)) __attribute_optimization_barrier__
is_aligned_p (void *p, int align) is_aligned_p (void *p, int align)
{ {
return (((uintptr_t) p) & (align - 1)) == 0; return (((uintptr_t) p) & (align - 1)) == 0;

View file

@ -16,15 +16,17 @@
License along with the GNU C Library; if not, see License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */ <https://www.gnu.org/licenses/>. */
#include <sys/cdefs.h>
/* This program does not use the test harness because we want tight /* This program does not use the test harness because we want tight
control over the call graph. */ control over the call graph. */
__attribute__ ((noinline, noclone, weak)) void __attribute__ ((weak)) __attribute_optimization_barrier__ void
f1 (void) f1 (void)
{ {
} }
__attribute__ ((noinline, noclone, weak)) void __attribute__ ((weak)) __attribute_optimization_barrier__ void
f2 (void) f2 (void)
{ {
f1 (); f1 ();
@ -32,7 +34,7 @@ f2 (void)
asm volatile (""); asm volatile ("");
} }
__attribute__ ((noinline, noclone, weak)) void __attribute__ ((weak)) __attribute_optimization_barrier__ void
f3 (int count) f3 (int count)
{ {
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)

View file

@ -16,6 +16,8 @@
License along with the GNU C Library; if not, see License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */ <https://www.gnu.org/licenses/>. */
#include <sys/cdefs.h>
/* Program with sufficiently complex, yet pointless, call graph /* Program with sufficiently complex, yet pointless, call graph
that it will trigger an mcount overflow, when you set the that it will trigger an mcount overflow, when you set the
minarcs/maxarcs tunables to very low values. */ minarcs/maxarcs tunables to very low values. */
@ -31,12 +33,12 @@
/* Defines 16 leaf functions named f1_0 to f1_15 */ /* Defines 16 leaf functions named f1_0 to f1_15 */
#define REP(n) \ #define REP(n) \
__attribute__ ((noinline, noclone, weak)) void f1_##n (void) {}; __attribute__ ((weak)) __attribute_optimization_barrier__ void f1_##n (void) {};
REPS REPS
#undef REP #undef REP
/* Calls all 16 leaf functions f1_* in succession */ /* Calls all 16 leaf functions f1_* in succession */
__attribute__ ((noinline, noclone, weak)) void __attribute__ ((weak)) __attribute_optimization_barrier__ void
f2 (void) f2 (void)
{ {
# define REP(n) f1_##n(); # 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 */ /* Defines 16 functions named f2_0 to f2_15, which all just call f2 */
#define REP(n) \ #define REP(n) \
__attribute__ ((noinline, noclone, weak)) void \ __attribute__ ((weak)) __attribute_optimization_barrier__ void \
f2_##n (void) { f2(); PREVENT_TAIL_CALL; }; f2_##n (void) { f2(); PREVENT_TAIL_CALL; };
REPS REPS
#undef REP #undef REP
__attribute__ ((noinline, noclone, weak)) void __attribute__ ((weak)) __attribute_optimization_barrier__ void
f3 (int count) f3 (int count)
{ {
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)

View file

@ -56,4 +56,11 @@ rtld_hidden_proto (__chk_fail)
#endif /* !defined _ISOMAC */ #endif /* !defined _ISOMAC */
/* Prevents a function from being considered for inlining and cloning. */
#ifdef __clang__
# define __attribute_optimization_barrier__ __attribute__ ((optnone))
#else
# define __attribute_optimization_barrier__ __attribute__ ((noinline, noclone))
#endif
#endif #endif

View file

@ -42,7 +42,7 @@ static int inner_thread_count = 4;
static size_t malloc_size = 32; static size_t malloc_size = 32;
static void static void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
unoptimized_free (void *ptr) unoptimized_free (void *ptr)
{ {
free (ptr); free (ptr);

View file

@ -33,7 +33,7 @@
/* Wrapper for calloc with an optimization barrier. */ /* Wrapper for calloc with an optimization barrier. */
static void * static void *
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
allocate_zeroed (size_t a, size_t b) allocate_zeroed (size_t a, size_t b)
{ {
return calloc (a, b); return calloc (a, b);

View file

@ -366,7 +366,7 @@ full_heap_check (void)
} }
/* Used as an optimization barrier to force a heap allocation. */ /* Used as an optimization barrier to force a heap allocation. */
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static void static void
my_free (void *ptr) my_free (void *ptr)
{ {

View file

@ -37,7 +37,7 @@ struct Array
static int error_count; static int error_count;
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
struct Array struct Array
allocate (size_t bytes) allocate (size_t bytes)
{ {
@ -52,7 +52,7 @@ allocate (size_t bytes)
return __extension__ (struct Array) {bytes, p}; return __extension__ (struct Array) {bytes, p};
} }
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
void void
deallocate (struct Array b) deallocate (struct Array b)
{ {
@ -66,7 +66,7 @@ deallocate (struct Array b)
} }
} }
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
void * void *
do_mmap (void *addr, size_t length) do_mmap (void *addr, size_t length)
{ {
@ -74,7 +74,7 @@ do_mmap (void *addr, size_t length)
MAP_PRIVATE | MAP_ANON, -1, 0); MAP_PRIVATE | MAP_ANON, -1, 0);
} }
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
void * void *
reallocate (struct Array b) reallocate (struct Array b)
{ {
@ -86,7 +86,7 @@ reallocate (struct Array b)
return NULL; return NULL;
} }
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
void void
protect (struct Array b) protect (struct Array b)
{ {
@ -104,7 +104,7 @@ protect (struct Array b)
} }
} }
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
ssize_t ssize_t
do_read (int fd, void *ptr, struct Array b) do_read (int fd, void *ptr, struct Array b)
{ {
@ -116,7 +116,7 @@ do_read (int fd, void *ptr, struct Array b)
return 0; return 0;
} }
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
ssize_t ssize_t
do_write (int fd, void *ptr, struct Array b) do_write (int fd, void *ptr, struct Array b)
{ {

View file

@ -24,7 +24,7 @@
#include <support/xthread.h> #include <support/xthread.h>
/* Throw a std::runtime_exception. */ /* Throw a std::runtime_exception. */
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
do_throw_exception () do_throw_exception ()
{ {
@ -38,17 +38,17 @@ struct class_with_destructor
~class_with_destructor (); ~class_with_destructor ();
}; };
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
class_with_destructor::class_with_destructor () class_with_destructor::class_with_destructor ()
{ {
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
class_with_destructor::~class_with_destructor () class_with_destructor::~class_with_destructor ()
{ {
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
function_with_destructed_object () function_with_destructed_object ()
{ {

View file

@ -73,7 +73,7 @@ enum { no_check = -1 };
/* Check that VALUE is the magic value for INDEX, behind a compiler /* Check that VALUE is the magic value for INDEX, behind a compiler
barrier. */ barrier. */
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_magic (int index, unsigned int value) 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 /* Check that VALUE is the magic value for INDEX, behind a compiler
barrier. Double variant. */ barrier. Double variant. */
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_magic (int index, double value) check_magic (int index, double value)
{ {
@ -153,7 +153,7 @@ struct checker
call_pthread_exit are used to call pthread_exit indirectly, with call_pthread_exit are used to call pthread_exit indirectly, with
the intent of clobbering the register values. */ the intent of clobbering the register values. */
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
call_pthread_exit_0 (const values<unsigned int> *pvalues) 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); pthread_exit (NULL);
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
call_pthread_exit_1 (const values<double> *pvalues) 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); call_pthread_exit_0 (&other_values);
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
call_pthread_exit () call_pthread_exit ()
{ {
@ -192,7 +192,7 @@ call_pthread_exit ()
pthread_exit. If Nested is true, call pthread_exit indirectly via pthread_exit. If Nested is true, call pthread_exit indirectly via
call_pthread_exit. */ call_pthread_exit. */
template <class T, bool Nested> template <class T, bool Nested>
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void * void *
threadfunc (void *closure) threadfunc (void *closure)
{ {

View file

@ -53,27 +53,27 @@ to_string (const counter &c)
template <counter *Counter> template <counter *Counter>
struct counting struct counting
{ {
counting () __attribute__ ((noinline, noclone)); counting () __attribute_optimization_barrier__;
~counting () __attribute__ ((noinline, noclone)); ~counting () __attribute_optimization_barrier__;
void operation () __attribute__ ((noinline, noclone)); void operation () __attribute_optimization_barrier__;
}; };
template<counter *Counter> template<counter *Counter>
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
counting<Counter>::counting () counting<Counter>::counting ()
{ {
++Counter->constructed; ++Counter->constructed;
} }
template<counter *Counter> template<counter *Counter>
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
counting<Counter>::~counting () counting<Counter>::~counting ()
{ {
++Counter->destructed; ++Counter->destructed;
} }
template<counter *Counter> template<counter *Counter>
void __attribute__ ((noinline, noclone)) void __attribute_optimization_barrier__
counting<Counter>::operation () counting<Counter>::operation ()
{ {
// Optimization barrier. // Optimization barrier.

View file

@ -30,7 +30,7 @@ static const char *context;
/* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler /* Check that ADDRESS is aligned to ALIGNMENT bytes, behind a compiler
barrier. */ barrier. */
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align (void *address, size_t alignment) check_align (void *address, size_t alignment)
{ {
@ -45,7 +45,7 @@ check_align (void *address, size_t alignment)
/* Various alignment checking functions. */ /* Various alignment checking functions. */
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_int (void) check_align_int (void)
{ {
@ -53,7 +53,7 @@ check_align_int (void)
check_align (&a, __alignof__ (a)); check_align (&a, __alignof__ (a));
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_long (void) check_align_long (void)
{ {
@ -61,7 +61,7 @@ check_align_long (void)
check_align (&a, __alignof__ (a)); check_align (&a, __alignof__ (a));
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_long_long (void) check_align_long_long (void)
{ {
@ -69,7 +69,7 @@ check_align_long_long (void)
check_align (&a, __alignof__ (a)); check_align (&a, __alignof__ (a));
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_double (void) check_align_double (void)
{ {
@ -77,7 +77,7 @@ check_align_double (void)
check_align (&a, __alignof__ (a)); check_align (&a, __alignof__ (a));
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_4 (void) check_align_4 (void)
{ {
@ -85,7 +85,7 @@ check_align_4 (void)
check_align (&a, 4); check_align (&a, 4);
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_8 (void) check_align_8 (void)
{ {
@ -93,7 +93,7 @@ check_align_8 (void)
check_align (&a, 8); check_align (&a, 8);
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_16 (void) check_align_16 (void)
{ {
@ -105,7 +105,7 @@ check_align_16 (void)
check_align (&a, 16); check_align (&a, 16);
} }
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_align_32 (void) check_align_32 (void)
{ {
@ -120,7 +120,7 @@ check_align_32 (void)
} }
/* Call all the alignment checking functions. */ /* Call all the alignment checking functions. */
__attribute__ ((noinline, noclone, weak)) __attribute__ ((weak)) __attribute_optimization_barrier__
void void
check_alignments (void) check_alignments (void)
{ {

View file

@ -26,7 +26,7 @@ struct A
thread_local A a; thread_local A a;
void void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
optimization_barrier (A &) optimization_barrier (A &)
{ {
} }

View file

@ -37,7 +37,7 @@ static ucontext_t ctx;
static void f2 (void); static void f2 (void);
static void static void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
f1 (void) f1 (void)
{ {
printf ("start f1\n"); printf ("start f1\n");
@ -45,7 +45,7 @@ f1 (void)
} }
static void static void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
f2 (void) f2 (void)
{ {
printf ("start f2\n"); printf ("start f2\n");
@ -64,7 +64,7 @@ f3 (void)
} }
static int static int
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
do_test_1 (void) do_test_1 (void)
{ {
char st1[32768]; char st1[32768];

View file

@ -54,7 +54,7 @@ f1 (int a0, int a1, int a2, int a3)
} }
static void static void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
call_longjmp (void) call_longjmp (void)
{ {
longjmp_called = 1; longjmp_called = 1;

View file

@ -27,7 +27,7 @@ static volatile int done;
static void f2 (void); static void f2 (void);
static void static void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
f1 (void) f1 (void)
{ {
printf ("start f1\n"); printf ("start f1\n");
@ -35,7 +35,7 @@ f1 (void)
} }
static void static void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
f2 (void) f2 (void)
{ {
printf ("start f2\n"); printf ("start f2\n");

View file

@ -26,7 +26,7 @@ static ucontext_t ctx[3];
static atomic_int done; static atomic_int done;
static void static void
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
f2 (void) f2 (void)
{ {
printf ("start f2\n"); printf ("start f2\n");

View file

@ -26,7 +26,7 @@ static ucontext_t ctx[5];
static atomic_int done; static atomic_int done;
static void static void
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
f2 (void) f2 (void)
{ {
done++; done++;

View file

@ -29,7 +29,7 @@ const char *fmt2 = "\e[34m";
#define handle_error(msg) \ #define handle_error(msg) \
do { perror(msg); exit(EXIT_FAILURE); } while (0) do { perror(msg); exit(EXIT_FAILURE); } while (0)
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt) 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); printf(" %sfunc4: returning\e[0m\n", fmt);
} }
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt) 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); printf(" %sfunc3: returning\e[0m\n", fmt);
} }
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func1(void) func1(void)
{ {
@ -59,7 +59,7 @@ func1(void)
} }
} }
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func2(void) func2(void)
{ {

View file

@ -32,7 +32,7 @@ static jmp_buf jmpbuf;
#define handle_error(msg) \ #define handle_error(msg) \
do { perror(msg); exit(EXIT_FAILURE); } while (0) do { perror(msg); exit(EXIT_FAILURE); } while (0)
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func4(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt) 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); printf(" %sfunc4: returning\e[0m\n", fmt);
} }
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func3(ucontext_t *uocp, ucontext_t *ucp, const char *str, const char *fmt) 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); printf(" %sfunc3: returning\e[0m\n", fmt);
} }
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func1(void) func1(void)
{ {
@ -67,7 +67,7 @@ func1(void)
} }
} }
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
static void static void
func2(void) func2(void)
{ {

View file

@ -30,7 +30,7 @@ thread_local A a1;
thread_local A a2; thread_local A a2;
void void
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
optimization_barrier (A &) optimization_barrier (A &)
{ {
} }

View file

@ -97,7 +97,7 @@ static const unsigned char test_pattern[16] =
static ucontext_t uc_main, uc_co; static ucontext_t uc_main, uc_co;
static __attribute__ ((noinline, noclone)) int static __attribute_optimization_barrier__ int
use_test_buffer (unsigned char *buf) use_test_buffer (unsigned char *buf)
{ {
unsigned int sum = 0; unsigned int sum = 0;

View file

@ -20,7 +20,7 @@
#include <stdint.h> #include <stdint.h>
int int
__attribute__ ((weak, noclone, noinline)) __attribute__ ((weak)) __attribute_optimization_barrier__
is_aligned (void *p, int align) is_aligned (void *p, int align)
{ {
return (((uintptr_t) p) & (align - 1)) != 0; return (((uintptr_t) p) & (align - 1)) != 0;

View file

@ -25,7 +25,7 @@
extern void bar (void); extern void bar (void);
void void
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
test (void (*func_p) (void)) test (void (*func_p) (void))
{ {
func_p (); func_p ();

View file

@ -30,7 +30,7 @@ static ucontext_t ctx[5];
static atomic_int done; static atomic_int done;
static void static void
__attribute__((noinline, noclone)) __attribute_optimization_barrier__
f2 (void) f2 (void)
{ {
printf ("start f2\n"); printf ("start f2\n");

View file

@ -25,7 +25,7 @@
#include <x86intrin.h> #include <x86intrin.h>
#include <support/test-driver.h> #include <support/test-driver.h>
__attribute__ ((noclone, noinline)) __attribute_optimization_barrier__
static void static void
do_test_1 (void) do_test_1 (void)
{ {

View file

@ -27,7 +27,7 @@ extern int arch_prctl (int, ...);
#define X86_XSTATE_TILEDATA_ID 18 #define X86_XSTATE_TILEDATA_ID 18
/* Initialize tile config. */ /* Initialize tile config. */
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static void static void
init_tile_config (__tilecfg *tileinfo) init_tile_config (__tilecfg *tileinfo)
{ {

View file

@ -23,7 +23,7 @@
/* Fill the stack with non-zero values. This makes a crash in /* Fill the stack with non-zero values. This makes a crash in
snprintf more likely. */ snprintf more likely. */
static void __attribute__ ((noinline, noclone)) static void __attribute_optimization_barrier__
fill_stack (void) fill_stack (void)
{ {
char buffer[65536]; char buffer[65536];

View file

@ -22,7 +22,7 @@
#define STRING_SIZE 1024 #define STRING_SIZE 1024
char string1[STRING_SIZE]; char string1[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -36,7 +36,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -23,7 +23,7 @@
char string1[STRING_SIZE]; char string1[STRING_SIZE];
char string2[STRING_SIZE]; char string2[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -35,7 +35,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -23,7 +23,7 @@
char string1[STRING_SIZE]; char string1[STRING_SIZE];
char string2[STRING_SIZE]; char string2[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -35,7 +35,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -22,7 +22,7 @@
#define STRING_SIZE 1024 #define STRING_SIZE 1024
char string1[STRING_SIZE]; char string1[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -36,7 +36,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -22,7 +22,7 @@
#define STRING_SIZE 1024 #define STRING_SIZE 1024
char string1[STRING_SIZE]; char string1[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -30,7 +30,7 @@ prepare (void)
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -22,7 +22,7 @@
#define STRING_SIZE 1024 #define STRING_SIZE 1024
char string1[STRING_SIZE]; char string1[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -36,7 +36,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -40,7 +40,7 @@
CHAR string1[STRING_SIZE]; CHAR string1[STRING_SIZE];
CHAR string2[STRING_SIZE]; CHAR string2[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -52,7 +52,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -23,7 +23,7 @@
char string1[STRING_SIZE]; char string1[STRING_SIZE];
char string2[STRING_SIZE]; char string2[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -35,7 +35,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -22,7 +22,7 @@
#define STRING_SIZE 1024 #define STRING_SIZE 1024
char string1[STRING_SIZE]; char string1[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -35,7 +35,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -40,7 +40,7 @@
CHAR string1[STRING_SIZE]; CHAR string1[STRING_SIZE];
CHAR string2[STRING_SIZE]; CHAR string2[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -52,7 +52,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {
@ -62,7 +62,7 @@ function (void)
return 1; return 1;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function_overflow (void) function_overflow (void)
{ {
@ -72,7 +72,7 @@ function_overflow (void)
return 1; return 1;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function_overflow2 (void) function_overflow2 (void)
{ {

View file

@ -22,7 +22,7 @@
#define STRING_SIZE 1024 #define STRING_SIZE 1024
char string1[STRING_SIZE]; char string1[STRING_SIZE];
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
prepare (void) prepare (void)
{ {
@ -35,7 +35,7 @@ prepare (void)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
__attribute__ ((noinline, noclone)) __attribute_optimization_barrier__
static int static int
function (void) function (void)
{ {

View file

@ -44,7 +44,7 @@ typedef struct
} parameter_t; } parameter_t;
size_t size_t
__attribute__ ((weak, noinline, noclone)) __attribute__ ((weak)) __attribute_optimization_barrier__
do_strlen (parameter_t *a, int zero, const CHAR *str) do_strlen (parameter_t *a, int zero, const CHAR *str)
{ {
return CALL (a, str); return CALL (a, str);