This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix SRA and initializers


Andrew Pinski <pinskia@physics.uc.edu> writes:

> I noticed when you have a complex initializer in a constant decl
> and we decided to SRA the copy, we need to gimplify the initializer.
> Since gimplify_stmt does not mark the temporary variables for renaming,
> we get an ICE because the variables are not renamed.  The easy way and
> correct way to fix this is to change over to use force_gimple_operand
> instead of gimplify_stmt.
>
> This fixes the Ada bootstrap failure on powerpc-darwin.
>
> OK? Bootstrapped and tested on powerpc-darwin with no regressions.

I'll test this now on ppc-linux - I would appreciate a review of this
patch so that Ada bootstrap again on PowerPC,

Andreas

> Thanks,
> Andrew Pinski
>
> ChangeLog:
>
> 	* tree-sra.c (generate_one_element_init): Use force_gimple_operand
> 	instead of gimplify_stmt.
> 	(scalarize_init): Do not call
> 	push_gimplify_context/pop_gimplify_context.
>
>
>
> Index: tree-sra.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/tree-sra.c,v
> retrieving revision 2.47
> diff -u -p -r2.47 tree-sra.c
> --- tree-sra.c	10 Dec 2004 21:54:42 -0000	2.47
> +++ tree-sra.c	22 Dec 2004 20:38:47 -0000
> @@ -1563,22 +1563,30 @@ generate_element_zero (struct sra_elt *e
>  static void
>  generate_one_element_init (tree var, tree init, tree *list_p)
>  {
> -  tree stmt;
> +  tree stmts, stmt;
> +  tree other;
> +  
> +  other = force_gimple_operand (init, &stmts, false, var);
>  
>    /* The replacement can be almost arbitrarily complex.  Gimplify.  */
> -  stmt = build (MODIFY_EXPR, void_type_node, var, init);
> -  gimplify_stmt (&stmt);
> -
> -  /* The replacement can expose previously unreferenced variables.  */
> -  if (TREE_CODE (stmt) == STATEMENT_LIST)
> +  stmt = build (MODIFY_EXPR, void_type_node, var, other);
> +  
> +  if (stmts)
>      {
> -      tree_stmt_iterator i;
> -      for (i = tsi_start (stmt); !tsi_end_p (i); tsi_next (&i))
> -	find_new_referenced_vars (tsi_stmt_ptr (i));
> +      /* The replacement can expose previously unreferenced variables.  */
> +      if (TREE_CODE (stmts) == STATEMENT_LIST)
> +	{
> +	  tree_stmt_iterator i;
> +	  for (i = tsi_start (stmts); !tsi_end_p (i); tsi_next (&i))
> +	    find_new_referenced_vars (tsi_stmt_ptr (i));
> +	}
> +      else
> +	find_new_referenced_vars (&stmts);
> +      
> +      append_to_statement_list (stmts, list_p);
>      }
> -  else
> -    find_new_referenced_vars (&stmt);
>  
> +  
>    append_to_statement_list (stmt, list_p);
>  }
>  
> @@ -1840,9 +1848,7 @@ scalarize_init (struct sra_elt *lhs_elt,
>      {
>        /* Unshare the expression just in case this is from a decl's initial.  */
>        rhs = unshare_expr (rhs);
> -      push_gimplify_context ();
>        result = generate_element_init (lhs_elt, rhs, &list);
> -      pop_gimplify_context (NULL);
>      }
>  
>    /* CONSTRUCTOR is defined such that any member not mentioned is assigned

Andreas
-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SUSE Linux Products GmbH, Maxfeldstr. 5, 90409 NÃrnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]