public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tsan: Don't instrument non-generic AS accesses [PR111736]
@ 2024-03-26  9:19 Jakub Jelinek
  2024-03-26  9:33 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2024-03-26  9:19 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

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.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

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/tsan.cc.jj	2024-01-03 11:51:29.155764166 +0100
+++ gcc/tsan.cc	2024-03-25 10:36:07.602861266 +0100
@@ -139,6 +139,9 @@ instrument_expr (gimple_stmt_iterator gs
   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);
--- gcc/testsuite/gcc.dg/tsan/pr111736.c.jj	2024-03-25 10:38:07.663191030 +0100
+++ gcc/testsuite/gcc.dg/tsan/pr111736.c	2024-03-25 10:43:08.071008937 +0100
@@ -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;
+}

	Jakub


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

* Re: [PATCH] tsan: Don't instrument non-generic AS accesses [PR111736]
  2024-03-26  9:19 [PATCH] tsan: Don't instrument non-generic AS accesses [PR111736] Jakub Jelinek
@ 2024-03-26  9:33 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-03-26  9:33 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, 26 Mar 2024, Jakub Jelinek wrote:

> Hi!
> 
> 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.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 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/tsan.cc.jj	2024-01-03 11:51:29.155764166 +0100
> +++ gcc/tsan.cc	2024-03-25 10:36:07.602861266 +0100
> @@ -139,6 +139,9 @@ instrument_expr (gimple_stmt_iterator gs
>    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);
> --- gcc/testsuite/gcc.dg/tsan/pr111736.c.jj	2024-03-25 10:38:07.663191030 +0100
> +++ gcc/testsuite/gcc.dg/tsan/pr111736.c	2024-03-25 10:43:08.071008937 +0100
> @@ -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;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

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

end of thread, other threads:[~2024-03-26  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26  9:19 [PATCH] tsan: Don't instrument non-generic AS accesses [PR111736] Jakub Jelinek
2024-03-26  9:33 ` Richard Biener

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