tsan.c (pass_tsan::gate): Add no_sanitize_thread support.
authorMike Stump <mikestump@comcast.net>
Thu, 8 Jan 2015 18:56:11 +0000 (18:56 +0000)
committerMike Stump <mrs@gcc.gnu.org>
Thu, 8 Jan 2015 18:56:11 +0000 (18:56 +0000)
* tsan.c (pass_tsan::gate): Add no_sanitize_thread support.
  (pass_tsan_O0::gate): Likewise.
* extend.texi (Function Attributes): Add no_sanitize_thread
  documentation.

* c-common.c (c_common_attribute_table): Add no_sanitize_thread.

From-SVN: r219355

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/doc/extend.texi
gcc/tsan.c

index 5bc6591af55872028573eb28eb1988f6424f23f8..f9b3c559a959c5244bdc1283a6489b39feea96c7 100644 (file)
@@ -1,3 +1,10 @@
+2015-01-08  Mike Stump  <mikestump@comcast.net>
+
+       * tsan.c (pass_tsan::gate): Add no_sanitize_thread support.
+       (pass_tsan_O0::gate): Likewise.
+       * extend.texi (Function Attributes): Add no_sanitize_thread
+       documentation.
+
 2015-01-08  Thomas Schwinge  <thomas@codesourcery.com>
 
        * builtins.def (DEF_GOMP_BUILTIN): Also consider flag_offload_abi
index 4bcff011315109cb6c25652b36589ffe9f41861a..d6f09dcf0441ec8c3418497b7eab6462a95f6635 100644 (file)
@@ -1,3 +1,7 @@
+2015-01-08  Mike Stump  <mikestump@comcast.net>
+
+       * c-common.c (c_common_attribute_table): Add no_sanitize_thread.
+
 2015-01-07  Marek Polacek  <polacek@redhat.com>
 
        PR c/64440
index df4fddd19265e27d1c52e4c060cb00f36a176a0b..713dca9fa9662bbe3b4b43111cd1eab95e51a2c9 100644 (file)
@@ -764,6 +764,9 @@ const struct attribute_spec c_common_attribute_table[] =
   { "no_sanitize_address",    0, 0, true, false, false,
                              handle_no_sanitize_address_attribute,
                              false },
+  { "no_sanitize_thread",     0, 0, true, false, false,
+                             handle_no_sanitize_address_attribute,
+                             false },
   { "no_sanitize_undefined",  0, 0, true, false, false,
                              handle_no_sanitize_undefined_attribute,
                              false },
index 25226824043dd404ec030b335880a59268991cf1..942a6bc8715ceddf577c9f25f40b5649e519cb2d 100644 (file)
@@ -2205,6 +2205,7 @@ attributes are currently defined for functions on all targets:
 @code{returns_nonnull}, @code{gnu_inline},
 @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
 @code{no_sanitize_address}, @code{no_address_safety_analysis},
+@code{no_sanitize_thread},
 @code{no_sanitize_undefined}, @code{no_reorder}, @code{bnd_legacy},
 @code{bnd_instrument},
 @code{error} and @code{warning}.
@@ -3721,6 +3722,12 @@ The @code{no_address_safety_analysis} is a deprecated alias of the
 @code{no_sanitize_address} attribute, new code should use
 @code{no_sanitize_address}.
 
+@item no_sanitize_thread
+@cindex @code{no_sanitize_thread} function attribute
+The @code{no_sanitize_thread} attribute on functions is used
+to inform the compiler that it should not instrument memory accesses
+in the function when compiling with the @option{-fsanitize=thread} option.
+
 @item no_sanitize_undefined
 @cindex @code{no_sanitize_undefined} function attribute
 The @code{no_sanitize_undefined} attribute on functions is used
index 567a4218bcd72674ce5e7d98251b98ec65d7609b..2dfbab0c777b979a340d39eaa896d9fd6a8eda6f 100644 (file)
@@ -868,7 +868,9 @@ public:
   opt_pass * clone () { return new pass_tsan (m_ctxt); }
   virtual bool gate (function *)
 {
-  return (flag_sanitize & SANITIZE_THREAD) != 0;
+  return ((flag_sanitize & SANITIZE_THREAD) != 0
+         && !lookup_attribute ("no_sanitize_thread",
+                                DECL_ATTRIBUTES (current_function_decl)));
 }
 
   virtual unsigned int execute (function *) { return tsan_pass (); }
@@ -908,7 +910,9 @@ public:
   /* opt_pass methods: */
   virtual bool gate (function *)
     {
-      return (flag_sanitize & SANITIZE_THREAD) != 0 && !optimize;
+      return ((flag_sanitize & SANITIZE_THREAD) != 0 && !optimize
+             && !lookup_attribute ("no_sanitize_thread",
+                                   DECL_ATTRIBUTES (current_function_decl)));
     }
 
   virtual unsigned int execute (function *) { return tsan_pass (); }