Patchwork Don't instrument with -fsanitize=thread accesses to DECL_HARD_REGISTER vars (PR tree-optimization/57104)

login
register
mail settings
Submitter Jakub Jelinek
Date April 29, 2013, 7:14 p.m.
Message ID <20130429191415.GJ28963@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/240484/
State New
Headers show

Comments

Jakub Jelinek - April 29, 2013, 7:14 p.m.
Hi!

DECL_HARD_REGISTER vars don't live in memory, thus they can't be
addressable.

The following patch fixes the ICE, ok for trunk/4.8?

2013-04-29  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/57104
	* tsan.c (instrument_expr): Don't instrument accesses to
	DECL_HARD_REGISTER VAR_DECLs.

	* gcc.dg/pr57104.c: New test.


	Jakub
Richard Guenther - April 30, 2013, 8:05 a.m.
On Mon, Apr 29, 2013 at 9:14 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> DECL_HARD_REGISTER vars don't live in memory, thus they can't be
> addressable.
>
> The following patch fixes the ICE, ok for trunk/4.8?

Ok.

Thanks,
Richard.

> 2013-04-29  Jakub Jelinek  <jakub@redhat.com>
>
>         PR tree-optimization/57104
>         * tsan.c (instrument_expr): Don't instrument accesses to
>         DECL_HARD_REGISTER VAR_DECLs.
>
>         * gcc.dg/pr57104.c: New test.
>
> --- gcc/tsan.c.jj       2013-04-24 12:07:12.000000000 +0200
> +++ gcc/tsan.c  2013-04-29 21:06:48.975888478 +0200
> @@ -128,7 +128,9 @@ instrument_expr (gimple_stmt_iterator gs
>         return false;
>      }
>
> -  if (TREE_READONLY (base))
> +  if (TREE_READONLY (base)
> +      || (TREE_CODE (base) == VAR_DECL
> +         && DECL_HARD_REGISTER (base)))
>      return false;
>
>    if (size == 0
> --- gcc/testsuite/gcc.dg/pr57104.c.jj   2013-04-29 21:09:46.812948131 +0200
> +++ gcc/testsuite/gcc.dg/pr57104.c      2013-04-29 21:09:39.000000000 +0200
> @@ -0,0 +1,12 @@
> +/* PR tree-optimization/57104 */
> +/* { dg-do compile { target { x86_64-*-linux* && lp64 } } } */
> +/* { dg-options "-fsanitize=thread" } */
> +
> +register int r asm ("r14");
> +int v;
> +
> +int
> +foo (void)
> +{
> +  return r + v;
> +}
>
>         Jakub

Patch

--- gcc/tsan.c.jj	2013-04-24 12:07:12.000000000 +0200
+++ gcc/tsan.c	2013-04-29 21:06:48.975888478 +0200
@@ -128,7 +128,9 @@  instrument_expr (gimple_stmt_iterator gs
 	return false;
     }
 
-  if (TREE_READONLY (base))
+  if (TREE_READONLY (base)
+      || (TREE_CODE (base) == VAR_DECL
+	  && DECL_HARD_REGISTER (base)))
     return false;
 
   if (size == 0
--- gcc/testsuite/gcc.dg/pr57104.c.jj	2013-04-29 21:09:46.812948131 +0200
+++ gcc/testsuite/gcc.dg/pr57104.c	2013-04-29 21:09:39.000000000 +0200
@@ -0,0 +1,12 @@ 
+/* PR tree-optimization/57104 */
+/* { dg-do compile { target { x86_64-*-linux* && lp64 } } } */
+/* { dg-options "-fsanitize=thread" } */
+
+register int r asm ("r14");
+int v;
+
+int
+foo (void)
+{
+  return r + v;
+}