From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17612 invoked by alias); 3 Apr 2011 10:45:20 -0000 Received: (qmail 17603 invoked by uid 22791); 3 Apr 2011 10:45:20 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 03 Apr 2011 10:45:15 +0000 Received: by wye20 with SMTP id 20so4668222wye.20 for ; Sun, 03 Apr 2011 03:45:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.165.194 with SMTP id j2mr6157515wby.178.1301827514102; Sun, 03 Apr 2011 03:45:14 -0700 (PDT) Received: by 10.227.0.140 with HTTP; Sun, 3 Apr 2011 03:45:14 -0700 (PDT) In-Reply-To: References: <4D9429C4.4040409@gnu.org> Date: Sun, 03 Apr 2011 10:45:00 -0000 Message-ID: Subject: Re: Random cleanups [2/4]: canonicalize ctor values From: Richard Guenther To: Michael Matz Cc: Paolo Bonzini , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg00148.txt.bz2 On Sun, Apr 3, 2011 at 12:14 PM, Michael Matz wrote: > Hi, > > On Thu, 31 Mar 2011, Richard Guenther wrote: > >> > In the meanwhile, is the below version okay? >> >> If it bootstraps & tests ok then yes. =A0The java parts look obvious. > > So, we indeed can't remove the other calls to > canonicalize_constructor_val, because of local ctors. =A0And fortran has a > similar problem with java. =A0Instead of fixing up all these places of > resetting cfun (where otherwise the frontends don't deal at all with it, > it's mostly just set from the various cgraph routines), I decided to > simply clear this at the appropriate place in > cgraph_finalize_compilation_unit. > > Regstrapping in progress again. =A0Still okay if that works? Ok. Thanks, Richard. > > Ciao, > Michael. > -- > =A0 =A0 =A0 =A0* cgraphbuild.c (record_reference): Canonicalize construct= or > =A0 =A0 =A0 =A0values. > =A0 =A0 =A0 =A0* gimple-fold.c (canonicalize_constructor_val): Accept bei= ng called > =A0 =A0 =A0 =A0without function context. > =A0 =A0 =A0 =A0* cgraphunit.c (cgraph_finalize_compilation_unit): Clear > =A0 =A0 =A0 =A0current_function_decl and cfun. > > Index: cgraphbuild.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- cgraphbuild.c.orig =A02011-04-03 11:28:45.000000000 +0200 > +++ cgraphbuild.c =A0 =A0 =A0 2011-04-03 11:31:21.000000000 +0200 > @@ -53,6 +53,12 @@ record_reference (tree *tp, int *walk_su > =A0 tree decl; > =A0 struct record_reference_ctx *ctx =3D (struct record_reference_ctx *)d= ata; > > + =A0t =3D canonicalize_constructor_val (t); > + =A0if (!t) > + =A0 =A0t =3D *tp; > + =A0else if (t !=3D *tp) > + =A0 =A0*tp =3D t; > + > =A0 switch (TREE_CODE (t)) > =A0 =A0 { > =A0 =A0 case VAR_DECL: > Index: gimple-fold.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- gimple-fold.c.orig =A02011-04-03 11:28:45.000000000 +0200 > +++ gimple-fold.c =A0 =A0 =A0 2011-04-03 11:31:21.000000000 +0200 > @@ -106,7 +106,7 @@ can_refer_decl_in_current_unit_p (tree d > =A0 return true; > =A0} > > -/* CVAL is value taken from DECL_INITIAL of variable. =A0Try to transorm= it into > +/* CVAL is value taken from DECL_INITIAL of variable. =A0Try to transfor= m it into > =A0 =A0acceptable form for is_gimple_min_invariant. =A0 */ > > =A0tree > @@ -131,10 +131,9 @@ canonicalize_constructor_val (tree cval) > =A0 =A0 =A0 =A0 =A0 =A0 =A0|| TREE_CODE (base) =3D=3D FUNCTION_DECL) > =A0 =A0 =A0 =A0 =A0&& !can_refer_decl_in_current_unit_p (base)) > =A0 =A0 =A0 =A0return NULL_TREE; > - =A0 =A0 =A0if (base && TREE_CODE (base) =3D=3D VAR_DECL) > + =A0 =A0 =A0if (cfun && base && TREE_CODE (base) =3D=3D VAR_DECL) > =A0 =A0 =A0 =A0add_referenced_var (base); > - =A0 =A0 =A0/* We never have the chance to fixup types in global initial= izers > - =A0 =A0 =A0 =A0 during gimplification. =A0Do so here. =A0*/ > + =A0 =A0 =A0/* Fixup types in global initializers. =A0*/ > =A0 =A0 =A0 if (TREE_TYPE (TREE_TYPE (cval)) !=3D TREE_TYPE (TREE_OPERAND= (cval, 0))) > =A0 =A0 =A0 =A0cval =3D build_fold_addr_expr (TREE_OPERAND (cval, 0)); > =A0 =A0 } > Index: cgraphunit.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- cgraphunit.c.orig =A0 2011-04-03 11:41:46.000000000 +0200 > +++ cgraphunit.c =A0 =A0 =A0 =A02011-04-03 11:50:01.000000000 +0200 > @@ -1066,6 +1066,11 @@ cgraph_finalize_compilation_unit (void) > =A0{ > =A0 timevar_push (TV_CGRAPH); > > + =A0/* If we're here there's no current function anymore. =A0Some fronte= nds > + =A0 =A0 are lazy in clearing these. =A0*/ > + =A0current_function_decl =3D NULL; > + =A0set_cfun (NULL); > + > =A0 /* Do not skip analyzing the functions if there were errors, we > =A0 =A0 =A0miss diagnostics for following functions otherwise. =A0*/ > >