public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR97868-tsan-fences)] Add -Wtsan.
@ 2020-12-07 14:56 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2020-12-07 14:56 UTC (permalink / raw)
  To: gcc-cvs

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;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/marxin/heads/PR97868-tsan-fences)] Add -Wtsan.
@ 2020-12-11 10:04 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2020-12-11 10:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7c982d06749fd3650825a5fb417e5e3487ecbcaf

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

    Add -Wtsan.
    
    gcc/ChangeLog:
    
            PR sanitizer/97868
            * common.opt: Add new warning -Wtsan.
            * doc/invoke.texi: Likewise.
            * tsan.c (instrument_builtin_call): Warn users about unsupported
            std::atomic_thread_fence.
    
    gcc/testsuite/ChangeLog:
    
            PR sanitizer/97868
            * gcc.dg/tsan/atomic-fence.c: New test.

Diff:
---
 gcc/common.opt                           |  4 ++++
 gcc/doc/invoke.texi                      |  8 +++++++-
 gcc/testsuite/gcc.dg/tsan/atomic-fence.c | 11 +++++++++++
 gcc/tsan.c                               |  6 ++++++
 4 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 6645539f5e5..4ab5fe44737 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 ThreadSanitizer.
+
 Xassembler
 Driver Separate
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8b871e8bffd..abd2d3145fc 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -377,7 +377,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wswitch  -Wno-switch-bool  -Wswitch-default  -Wswitch-enum @gol
 -Wno-switch-outside-range  -Wno-switch-unreachable  -Wsync-nand @gol
 -Wsystem-headers  -Wtautological-compare  -Wtrampolines  -Wtrigraphs @gol
--Wtype-limits  -Wundef @gol
+-Wtsan -Wtype-limits  -Wundef @gol
 -Wuninitialized  -Wunknown-pragmas @gol
 -Wunsuffixed-float-constants  -Wunused @gol
 -Wunused-but-set-parameter  -Wunused-but-set-variable @gol
@@ -7951,6 +7951,12 @@ Note that the code above is invalid in C++11.
 
 This warning is enabled by default.
 
+@item -Wtsan
+@opindex Wtsan
+@opindex Wno-tsan
+Warn about unsupported features in ThreadSanitizer.
+This warning is enabled by default.
+
 @item -Wtype-limits
 @opindex Wtype-limits
 @opindex Wno-type-limits
diff --git a/gcc/testsuite/gcc.dg/tsan/atomic-fence.c b/gcc/testsuite/gcc.dg/tsan/atomic-fence.c
new file mode 100644
index 00000000000..013720c2969
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tsan/atomic-fence.c
@@ -0,0 +1,11 @@
+/* PR sanitizer/97868 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=thread" } */
+
+int
+main ()
+{
+  __atomic_thread_fence (__ATOMIC_RELAXED); /* { dg-warning ".atomic_thread_fence. is not supported with .-fsanitize=thread." } */
+  return 0;
+}
+
diff --git a/gcc/tsan.c b/gcc/tsan.c
index 4d6223454b5..1bc020e7648 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 with %qs", "atomic_thread_fence",
+		      "-fsanitize=thread");
+
 	tree decl = builtin_decl_implicit (tsan_atomic_table[i].tsan_fcode);
 	if (decl == NULL_TREE)
 	  return;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/marxin/heads/PR97868-tsan-fences)] Add -Wtsan.
@ 2020-12-09  9:23 Martin Liska
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liska @ 2020-12-09  9:23 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4a887ebb176d553df572afb24fe8f2c32e00f1c5

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

    Add -Wtsan.
    
    gcc/ChangeLog:
    
            PR sanitizer/97868
            * common.opt: Add new warning -Wtsan.
            * doc/invoke.texi: Likewise.
            * tsan.c (instrument_builtin_call): Warn users about unsupported
            std::atomic_thread_fence.

Diff:
---
 gcc/common.opt      | 4 ++++
 gcc/doc/invoke.texi | 8 +++++++-
 gcc/tsan.c          | 6 ++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

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/doc/invoke.texi b/gcc/doc/invoke.texi
index f7e8c8b29b0..5bd18c78e99 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -377,7 +377,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wswitch  -Wno-switch-bool  -Wswitch-default  -Wswitch-enum @gol
 -Wno-switch-outside-range  -Wno-switch-unreachable  -Wsync-nand @gol
 -Wsystem-headers  -Wtautological-compare  -Wtrampolines  -Wtrigraphs @gol
--Wtype-limits  -Wundef @gol
+-Wtsan -Wtype-limits  -Wundef @gol
 -Wuninitialized  -Wunknown-pragmas @gol
 -Wunsuffixed-float-constants  -Wunused @gol
 -Wunused-but-set-parameter  -Wunused-but-set-variable @gol
@@ -7951,6 +7951,12 @@ Note that the code above is invalid in C++11.
 
 This warning is enabled by default.
 
+@item -Wtsan
+@opindex Wtsan
+@opindex Wno-tsan
+Warn about unsupported features in the ThreadSanitizer.
+This warning is enabled by default.
+
 @item -Wtype-limits
 @opindex Wtype-limits
 @opindex Wno-type-limits
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;


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-11 10:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 14:56 [gcc(refs/users/marxin/heads/PR97868-tsan-fences)] Add -Wtsan Martin Liska
2020-12-09  9:23 Martin Liska
2020-12-11 10:04 Martin Liska

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).