diff mbox

Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

Message ID 047F6317-2B29-407A-A33E-94EBF782598C@comcast.net
State New
Headers show

Commit Message

Mike Stump Jan. 8, 2015, 7:09 p.m. UTC
On Jan 7, 2015, at 12:23 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> 
> I'm fine with adding the no_sanitize_thread attribute, the patch LGTM

Thanks, I checked it in, the doc seemed trivial enough.
* 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-family:
	* c-common.c (c_common_attribute_table): Add no_sanitize_thread.
diff mbox

Patch

Index: doc/extend.texi
===================================================================
--- doc/extend.texi	(revision 219354)
+++ doc/extend.texi	(revision 219355)
@@ -2205,6 +2205,7 @@  attributes are currently defined for fun
 @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
 @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: c-family/c-common.c
===================================================================
--- c-family/c-common.c	(revision 219354)
+++ c-family/c-common.c	(revision 219355)
@@ -764,6 +764,9 @@  const struct attribute_spec c_common_att
   { "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: tsan.c
===================================================================
--- tsan.c	(revision 219354)
+++ tsan.c	(revision 219355)
@@ -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 (); }