diff mbox

User-unfriendly artificial SRA replacements

Message ID 20100917125740.GC4049@virgil.arch.suse.de
State New
Headers show

Commit Message

Martin Jambor Sept. 17, 2010, 12:57 p.m. UTC
Hi,

this is a followup to my previous build_ref_for_offset patch.  If
build_user_friendly_ref_for_offset does not succeed when building an
artificial SRA access, we use build_ref_for_model which produces an
expression we cannot use in warnings and so I introduced a flag in the
access to remember that fact.

Bootstrapped and tested on x86_64-linux, ok for trunk?

Thanks,

Martin


2010-09-15  Martin Jambor  <mjambor@suse.cz>

	* tree-sra.c (struct access): New field grp_no_warning.
	(create_access_replacement): Set TREE_NO_WARNING according to
	 grp_no_warning.
	(create_artificial_child_access): Use build_ref_for_model and set
	grp_no_warning if build_user_friendly_ref_for_offset fails.
	(propagate_subaccesses_across_link): Likewise.

Comments

Richard Biener Sept. 20, 2010, 12:50 p.m. UTC | #1
On Fri, 17 Sep 2010, Martin Jambor wrote:

> Hi,
> 
> this is a followup to my previous build_ref_for_offset patch.  If
> build_user_friendly_ref_for_offset does not succeed when building an
> artificial SRA access, we use build_ref_for_model which produces an
> expression we cannot use in warnings and so I introduced a flag in the
> access to remember that fact.
> 
> Bootstrapped and tested on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> 
> Martin
> 
> 
> 2010-09-15  Martin Jambor  <mjambor@suse.cz>
> 
> 	* tree-sra.c (struct access): New field grp_no_warning.
> 	(create_access_replacement): Set TREE_NO_WARNING according to
> 	 grp_no_warning.
> 	(create_artificial_child_access): Use build_ref_for_model and set
> 	grp_no_warning if build_user_friendly_ref_for_offset fails.
> 	(propagate_subaccesses_across_link): Likewise.
> 
> Index: mine/gcc/tree-sra.c
> ===================================================================
> --- mine.orig/gcc/tree-sra.c
> +++ mine/gcc/tree-sra.c
> @@ -216,6 +216,9 @@ struct access
>       cannot be called from within FOR_EACH_REFERENCED_VAR. */
>    unsigned grp_to_be_replaced : 1;
>  
> +  /* Should TREE_NO_WARNING of a replacement be set?  */
> +  unsigned grp_no_warning : 1;
> +
>    /* Is it possible that the group refers to data which might be (directly or
>       otherwise) modified?  */
>    unsigned grp_maybe_modified : 1;
> @@ -1714,7 +1717,10 @@ create_access_replacement (struct access
>  	  }
>        SET_DECL_DEBUG_EXPR (repl, debug_expr);
>        DECL_DEBUG_EXPR_IS_FROM (repl) = 1;
> -      TREE_NO_WARNING (repl) = TREE_NO_WARNING (access->base);
> +      if (access->grp_no_warning)
> +	TREE_NO_WARNING (repl) = 1;
> +      else
> +	TREE_NO_WARNING (repl) = TREE_NO_WARNING (access->base);
>      }
>    else
>      TREE_NO_WARNING (repl) = 1;
> @@ -1970,12 +1976,17 @@ create_artificial_child_access (struct a
>    tree expr = parent->base;
>  
>    gcc_assert (!model->grp_unscalarizable_region);
> -  if (!build_user_friendly_ref_for_offset (&expr, TREE_TYPE (expr), new_offset,
> -					   model->type))
> -    return NULL;
>  
>    access = (struct access *) pool_alloc (access_pool);
>    memset (access, 0, sizeof (struct access));
> +  if (!build_user_friendly_ref_for_offset (&expr, TREE_TYPE (expr), new_offset,
> +					   model->type))
> +    {
> +      access->grp_no_warning = true;
> +      expr = build_ref_for_model (EXPR_LOCATION (parent->base), parent->base,
> +				  new_offset, model, NULL, false);
> +    }
> +
>    access->base = parent->base;
>    access->expr = expr;
>    access->offset = new_offset;
> @@ -2016,11 +2027,16 @@ propagate_subaccesses_across_link (struc
>      {
>        tree t = lacc->base;
>  
> +      lacc->type = racc->type;
>        if (build_user_friendly_ref_for_offset (&t, TREE_TYPE (t), lacc->offset,
>  					      racc->type))
> +	lacc->expr = t;
> +      else
>  	{
> -	  lacc->expr = t;
> -	  lacc->type = racc->type;
> +	  lacc->expr = build_ref_for_model (EXPR_LOCATION (lacc->base),
> +					    lacc->base, lacc->offset,
> +					    racc, NULL, false);
> +	  lacc->grp_no_warning = true;
>  	}
>        return false;
>      }
> 
>
H.J. Lu Sept. 26, 2011, 8:02 p.m. UTC | #2
On Fri, Sep 17, 2010 at 5:57 AM, Martin Jambor <mjambor@suse.cz> wrote:
> Hi,
>
> this is a followup to my previous build_ref_for_offset patch.  If
> build_user_friendly_ref_for_offset does not succeed when building an
> artificial SRA access, we use build_ref_for_model which produces an
> expression we cannot use in warnings and so I introduced a flag in the
> access to remember that fact.
>
> Bootstrapped and tested on x86_64-linux, ok for trunk?
>
> Thanks,
>
> Martin
>
>
> 2010-09-15  Martin Jambor  <mjambor@suse.cz>
>
>        * tree-sra.c (struct access): New field grp_no_warning.
>        (create_access_replacement): Set TREE_NO_WARNING according to
>         grp_no_warning.
>        (create_artificial_child_access): Use build_ref_for_model and set
>        grp_no_warning if build_user_friendly_ref_for_offset fails.
>        (propagate_subaccesses_across_link): Likewise.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50444
diff mbox

Patch

Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -216,6 +216,9 @@  struct access
      cannot be called from within FOR_EACH_REFERENCED_VAR. */
   unsigned grp_to_be_replaced : 1;
 
+  /* Should TREE_NO_WARNING of a replacement be set?  */
+  unsigned grp_no_warning : 1;
+
   /* Is it possible that the group refers to data which might be (directly or
      otherwise) modified?  */
   unsigned grp_maybe_modified : 1;
@@ -1714,7 +1717,10 @@  create_access_replacement (struct access
 	  }
       SET_DECL_DEBUG_EXPR (repl, debug_expr);
       DECL_DEBUG_EXPR_IS_FROM (repl) = 1;
-      TREE_NO_WARNING (repl) = TREE_NO_WARNING (access->base);
+      if (access->grp_no_warning)
+	TREE_NO_WARNING (repl) = 1;
+      else
+	TREE_NO_WARNING (repl) = TREE_NO_WARNING (access->base);
     }
   else
     TREE_NO_WARNING (repl) = 1;
@@ -1970,12 +1976,17 @@  create_artificial_child_access (struct a
   tree expr = parent->base;
 
   gcc_assert (!model->grp_unscalarizable_region);
-  if (!build_user_friendly_ref_for_offset (&expr, TREE_TYPE (expr), new_offset,
-					   model->type))
-    return NULL;
 
   access = (struct access *) pool_alloc (access_pool);
   memset (access, 0, sizeof (struct access));
+  if (!build_user_friendly_ref_for_offset (&expr, TREE_TYPE (expr), new_offset,
+					   model->type))
+    {
+      access->grp_no_warning = true;
+      expr = build_ref_for_model (EXPR_LOCATION (parent->base), parent->base,
+				  new_offset, model, NULL, false);
+    }
+
   access->base = parent->base;
   access->expr = expr;
   access->offset = new_offset;
@@ -2016,11 +2027,16 @@  propagate_subaccesses_across_link (struc
     {
       tree t = lacc->base;
 
+      lacc->type = racc->type;
       if (build_user_friendly_ref_for_offset (&t, TREE_TYPE (t), lacc->offset,
 					      racc->type))
+	lacc->expr = t;
+      else
 	{
-	  lacc->expr = t;
-	  lacc->type = racc->type;
+	  lacc->expr = build_ref_for_model (EXPR_LOCATION (lacc->base),
+					    lacc->base, lacc->offset,
+					    racc, NULL, false);
+	  lacc->grp_no_warning = true;
 	}
       return false;
     }