From 2f3c4b6968e969001578fddc4fac848b8726dde3 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 21 Jan 2015 18:08:42 +0000 Subject: [PATCH] gimplify.c (gimplify_function_tree): Check the no_sanitize_thread decl attribute. gcc/ChangeLog: 2015-01-21 Bernd Edlinger * gimplify.c (gimplify_function_tree): Check the no_sanitize_thread decl attribute. gcc/testsuite/ChangeLog 2015-01-21 Bernd Edlinger * gcc/testsuite/c-c++-common/tsan/step.c: New testcase. From-SVN: r219961 --- gcc/ChangeLog | 5 +++++ gcc/gimplify.c | 3 ++- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/tsan/step.c | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/tsan/step.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a08d231b72d..1c0a45e5e7f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-01-21 Bernd Edlinger + + * gimplify.c (gimplify_function_tree): Check the no_sanitize_thread + decl attribute. + 2015-01-21 David Sherwood Tejas Belagod diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 947b0af8d56..1353ada2f85 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9258,7 +9258,8 @@ gimplify_function_tree (tree fndecl) bind = new_bind; } - if (flag_sanitize & SANITIZE_THREAD) + if ((flag_sanitize & SANITIZE_THREAD) != 0 + && !lookup_attribute ("no_sanitize_thread", DECL_ATTRIBUTES (fndecl))) { gcall *call = gimple_build_call_internal (IFN_TSAN_FUNC_EXIT, 0); gimple tf = gimple_build_try (seq, call, GIMPLE_TRY_FINALLY); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f679c04144d..e1a4ce87cfc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-01-21 Bernd Edlinger + + * gcc/testsuite/c-c++-common/tsan/step.c: New testcase. + 2015-01-21 Christophe Lyon * gcc.target/aarch64/advsimd-intrinsics/vqdmull_n.c: New file. diff --git a/gcc/testsuite/c-c++-common/tsan/step.c b/gcc/testsuite/c-c++-common/tsan/step.c new file mode 100644 index 00000000000..ce9edd454a0 --- /dev/null +++ b/gcc/testsuite/c-c++-common/tsan/step.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +extern int sched_yield (void); +static volatile int serial = 0; + +__attribute__((no_sanitize_thread)) +void step (int i) +{ + while (__atomic_load_n (&serial, __ATOMIC_ACQUIRE) != i - 1) + sched_yield (); + __atomic_store_n (&serial, i, __ATOMIC_RELEASE); +} + +/* { dg-final { scan-assembler-not "__tsan_func_entry" } } */ +/* { dg-final { scan-assembler-not "__tsan_func_exit" } } */ -- 2.30.2