]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tsan: Don't instrument non-generic AS accesses [PR111736]
authorJakub Jelinek <jakub@redhat.com>
Tue, 26 Mar 2024 10:06:15 +0000 (11:06 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 26 Mar 2024 10:13:24 +0000 (11:13 +0100)
Similar to the asan and ubsan changes, we shouldn't instrument non-generic
address space accesses with tsan, because we just have library functions
which take address of the objects as generic address space pointers, so they
can't handle anything else.

2024-03-26  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/111736
* tsan.cc (instrument_expr): Punt on non-generic address space
accesses.

* gcc.dg/tsan/pr111736.c: New test.

gcc/testsuite/gcc.dg/tsan/pr111736.c [new file with mode: 0644]
gcc/tsan.cc

diff --git a/gcc/testsuite/gcc.dg/tsan/pr111736.c b/gcc/testsuite/gcc.dg/tsan/pr111736.c
new file mode 100644 (file)
index 0000000..34ab88b
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR sanitizer/111736 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-fsanitize=thread -fdump-tree-optimized -ffat-lto-objects" } */
+/* { dg-final { scan-tree-dump-not "__tsan_read" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__tsan_write" "optimized" } } */
+
+#ifdef __x86_64__
+#define SEG __seg_fs
+#else
+#define SEG __seg_gs
+#endif
+
+void
+foo (int SEG *p, int SEG *q)
+{
+  *q = *p;
+}
index e73e1d3717802218ca9409814af2711fefa0ad66..590e97d397bd655f97aaebd645c264725b390a8a 100644 (file)
@@ -139,6 +139,9 @@ instrument_expr (gimple_stmt_iterator gsi, tree expr, bool is_write)
   if (TREE_READONLY (base) || (VAR_P (base) && DECL_HARD_REGISTER (base)))
     return false;
 
+  if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (base))))
+    return false;
+
   stmt = gsi_stmt (gsi);
   loc = gimple_location (stmt);
   rhs = is_vptr_store (stmt, expr, is_write);