Two gimplification issues

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Sun Jul 25 21:43:00 GMT 2004


The first of these came up compiling the Ada file prj-part.adb.  Some items
in the elaboration procedure are gimplified before the procedure is
finalized, so they get gimplified twice.  This caused a problem since a
previous WITH_SIZE_EXPR wasn't be respected.  The double gimplification
isn't a good thing, but it's hard to fix and gimplifying something
twice shouldn't lose.  Also, I think you meant to do the memcpy case
for an INDIRECT_REF.

The second of these was a bugfix for ACATS test cb41002: nothing was
gimplifying the LHS, which in this case was an <indirect_ref <save_expr ..>>.

Tested on x86_64-linux-gnu.

Does this look right to you?

2004-07-25  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* gimplify.c (maybe_with_size_expr): If already have WITH_SIZE_EXPR,
	don't make another one.
	(gimplify_modify_expr): Handle INDIRECT_REF in variable size case.
	(gimplify_init_constructor): When making static case, gimplify the LHS.

*** gimplify.c	24 Jul 2004 01:29:11 -0000	2.54
--- gimplify.c	25 Jul 2004 13:28:03 -0000
*************** static void
*** 1747,1764 ****
  maybe_with_size_expr (tree *expr_p)
  {
!   tree expr, type, size;
  
!   expr = *expr_p;
!   type = TREE_TYPE (expr);
!   if (type == error_mark_node)
      return;
  
    size = TYPE_SIZE_UNIT (type);
!   if (size && TREE_CODE (size) != INTEGER_CST)
!     {
!       size = unshare_expr (size);
!       size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, expr);
!       *expr_p = build2 (WITH_SIZE_EXPR, type, expr, size);
!     }
  }
  
--- 1747,1769 ----
  maybe_with_size_expr (tree *expr_p)
  {
!   tree expr = *expr_p;
!   tree type = TREE_TYPE (expr);
!   tree size;
  
!   /* If we've already wrapped this or the type is error_mark_node, we can't do
!      anything.  */
!   if (TREE_CODE (expr) == WITH_SIZE_EXPR
!       || type == error_mark_node)
      return;
  
+   /* If the size isn't known or is a constant, we have nothing to do.  */
    size = TYPE_SIZE_UNIT (type);
!   if (!size || TREE_CODE (size) == INTEGER_CST)
!     return;
! 
!   /* Otherwise, make a WITH_SIZE_EXPR.  */
!   size = unshare_expr (size);
!   size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, expr);
!   *expr_p = build2 (WITH_SIZE_EXPR, type, expr, size);
  }
  
*************** gimplify_init_constructor (tree *expr_p,
*** 2460,2463 ****
--- 2465,2469 ----
  	      {
  		tree new = create_tmp_var_raw (type, "C");
+ 
  		gimple_add_tmp_var (new);
  		TREE_STATIC (new) = 1;
*************** gimplify_init_constructor (tree *expr_p,
*** 2472,2475 ****
--- 2478,2484 ----
  
  		TREE_OPERAND (*expr_p, 1) = new;
+ 
+ 		gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p, post_p,
+ 			       is_gimple_lvalue, fb_lvalue);
  		break;
  	      }
*************** gimplify_modify_expr (tree *expr_p, tree
*** 2789,2793 ****
        if (TREE_CODE (from) == CONSTRUCTOR)
  	return gimplify_modify_expr_to_memset (expr_p, size, want_value);
!       if (is_gimple_addr_expr_arg (from))
  	{
  	  *from_p = from;
--- 2798,2802 ----
        if (TREE_CODE (from) == CONSTRUCTOR)
  	return gimplify_modify_expr_to_memset (expr_p, size, want_value);
!       if (is_gimple_addr_expr_arg_or_indirect (from))
  	{
  	  *from_p = from;



More information about the Gcc-patches mailing list