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] PR32901: handle assignment...(and PR34465 and PR34448)


On Fri, Dec 14, 2007 at 05:25:27PM -0400, Aldy Hernandez wrote:
> This patch addresses Mark's concern regarding volatiles.  It also fixes
> 34448 by not allowing the optimization to run if
> gimplify_init_constructor will dump the constructor to memory.  And
> finally, it fixes the tree sharing problem in PR34465.

It looks good to me (though you need to find someone^H^H^H^H^H^H^HDiego to
approve it anyway), except that the unshare_expr is IMHO done too early,
wasting GC memory if gimplify_init_constructor returns GS_ERROR.  I believe
gimplify_init_constructor doesn't care if RHS is shared or unshared
and with true as last argument it shouldn't gimplify it either, so
IMHO doing:
  *from_p = DECL_INITIAL (*from_p);
before the gimplify_init_constructor and
  *from_p = unshare_expr (*from_p);
right before ret = GS_OK after it would work too and wouldn't waste memory
if the optimization is not applied.

> -	    *from_p = DECL_INITIAL (*from_p);
> -	    ret = GS_OK;
> +	    tree old_from = *from_p;
> +
> +	    /* Move the constructor into the RHS.  */
> +	    *from_p = unshare_expr (DECL_INITIAL (*from_p));
> +
> +	    /* Let's see if gimplify_init_constructor will need to put
> +	       it in memory.  If so, revert the change.  */
> +	    ret = gimplify_init_constructor (expr_p, NULL, NULL, false, true);
> +	    if (ret == GS_ERROR)
> +	      {
> +		*from_p = old_from;
> +		/* Fall through.  */
> +	      }
> +	    else
> +	      {
> +		ret = GS_OK;
> +		break;
> +	      }
>  	  }
>  	ret = GS_UNHANDLED;
>  	break;

	Jakub


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