Patchwork Avoid SRA-created debug binds with uninitialized RHSs

login
register
mail settings
Submitter Martin Jambor
Date Feb. 27, 2013, 3:08 p.m.
Message ID <20130227150809.GA11809@virgil.suse>
Download mbox | patch
Permalink /patch/223628/
State New
Headers show

Comments

Martin Jambor - Feb. 27, 2013, 3:08 p.m.
Hi,

looking at dumps of PR 56294 I have noticed that on one occasion, SRA
total scalarization mechanism replaced an uninitialized structure with
scalar replacements and these then happened to end up in DEBUG bind
statements describing another structure.  Such replacements then did
not end up in the IL anywhere else (and not at all in -g0).  SSA
renaming is clever enough to replace them with NULLs later on but if
the replacements are never initialized in the function, this can be
easily avoided.

Bootstrapped and tested on x86_64-linux without any issues.  So far I
do not know whether it is required to fix PR 56294 but the patch is
tiny and simply avoids unnecessary work so I'd like to ask for
approval to commit to trunk now.

Thanks,

Martin


2013-02-26  Martin Jambor  <mjambor@suse.cz>

	* tree-sra.c (load_assign_lhs_subreplacements): Do not put replacements
	with no initialization to the RHS of debug statements.
Jakub Jelinek - Feb. 27, 2013, 3:13 p.m.
On Wed, Feb 27, 2013 at 04:08:09PM +0100, Martin Jambor wrote:
> 2013-02-26  Martin Jambor  <mjambor@suse.cz>
> 
> 	* tree-sra.c (load_assign_lhs_subreplacements): Do not put replacements
> 	with no initialization to the RHS of debug statements.

Okay.

> --- src.orig/gcc/tree-sra.c
> +++ src/gcc/tree-sra.c
> @@ -2870,7 +2870,12 @@ load_assign_lhs_subreplacements (struct
>  							    lacc->size);
>  
>  	      if (racc && racc->grp_to_be_replaced)
> -		drhs = get_access_replacement (racc);
> +		{
> +		  if (racc->grp_write)
> +		    drhs = get_access_replacement (racc);
> +		  else
> +		    drhs = NULL;
> +		}
>  	      else if (*refreshed == SRA_UDH_LEFT)
>  		drhs = build_debug_ref_for_model (loc, lacc->base, lacc->offset,
>  						  lacc);

	Jakub

Patch

Index: src/gcc/tree-sra.c
===================================================================
--- src.orig/gcc/tree-sra.c
+++ src/gcc/tree-sra.c
@@ -2870,7 +2870,12 @@  load_assign_lhs_subreplacements (struct
 							    lacc->size);
 
 	      if (racc && racc->grp_to_be_replaced)
-		drhs = get_access_replacement (racc);
+		{
+		  if (racc->grp_write)
+		    drhs = get_access_replacement (racc);
+		  else
+		    drhs = NULL;
+		}
 	      else if (*refreshed == SRA_UDH_LEFT)
 		drhs = build_debug_ref_for_model (loc, lacc->base, lacc->offset,
 						  lacc);