public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/PR97868-tsan-fences)] Add -Wtsan.
Date: Mon,  7 Dec 2020 14:56:34 +0000 (GMT)	[thread overview]
Message-ID: <20201207145634.C58AA385783D@sourceware.org> (raw)

https://gcc.gnu.org/g:a644a9bb8ddb9803c9aa033dc86bb03ceac9e895

commit a644a9bb8ddb9803c9aa033dc86bb03ceac9e895
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Dec 7 15:55:59 2020 +0100

    Add -Wtsan.

Diff:
---
 gcc/common.opt | 4 ++++
 gcc/tsan.c     | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/gcc/common.opt b/gcc/common.opt
index 6645539f5e5..6c24c7bbffb 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -842,6 +842,10 @@ Wvector-operation-performance
 Common Var(warn_vector_operation_performance) Warning
 Warn when a vector operation is compiled outside the SIMD.
 
+Wtsan
+Common Var(warn_tsan) Init(1) Warning
+Warn about unsupported features in the ThreadSanitizer.
+
 Xassembler
 Driver Separate
 
diff --git a/gcc/tsan.c b/gcc/tsan.c
index 4d6223454b5..be9fabea62a 100644
--- a/gcc/tsan.c
+++ b/gcc/tsan.c
@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "asan.h"
 #include "builtins.h"
 #include "target.h"
+#include "diagnostic-core.h"
 
 /* Number of instrumented memory accesses in the current function.  */
 
@@ -500,6 +501,11 @@ instrument_builtin_call (gimple_stmt_iterator *gsi)
       continue;
     else
       {
+	if (fcode == BUILT_IN_ATOMIC_THREAD_FENCE)
+	  warning_at (gimple_location (stmt), OPT_Wtsan,
+		      "%qs is not supported by ThreadSanitizer and may "
+		      "lead to false positives", "atomic_thread_fence");
+
 	tree decl = builtin_decl_implicit (tsan_atomic_table[i].tsan_fcode);
 	if (decl == NULL_TREE)
 	  return;


             reply	other threads:[~2020-12-07 14:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 14:56 Martin Liska [this message]
2020-12-09  9:23 Martin Liska
2020-12-11 10:04 Martin Liska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201207145634.C58AA385783D@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).