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  <ja...@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 <rguent...@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to