This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PRs 33816, 32921 (again, different)
On Fri, 19 Oct 2007, Diego Novillo wrote:
> On 10/19/07, Richard Guenther <rguenther@suse.de> wrote:
>
> > This is too conservative, but we cannot call record_component_aliases
> > here because some frontends still change the aggregates after
> > layout_type. */
> > ! if (AGGREGATE_TYPE_P (type))
> > ! gcc_assert (!TYPE_ALIAS_SET_KNOWN_P (type));
>
> You'll need to change the comment here. Something like "Incomplete
> types should not have a known alias set.".
>
> > + /* We don't want to set TYPE_ALIAS_SET for incomplete types. */
> > + if (!COMPLETE_TYPE_P (t))
> > + {
> > + /* For arrays with unknown size the conservative answer is the
> > + alias set of the element type. */
> > + if (TREE_CODE (t) == ARRAY_TYPE)
> > + return get_alias_set (TREE_TYPE (t));
> > +
> > + /* But return zero as a conservative answer for incomplete types. */
> > + return 0;
> > + }
>
> This makes sense to me. If the type is still incomplete we don't want
> to commit to consider its alias set as known and fixed.
Bootstrapped and tested on x86_64-unknown-linux-gnu for all languages
including Ada. The following is what I applied.
Richard.
2007-10-19 Richard Guenther <rguenther@suse.de>
PR middle-end/33816
PR middle-end/32921
* stor-layout.c (layout_type): Assert that aggregates do not
have their alias sets set.
* alias.c (get_alias_set): Return alias set zero for incomplete
types, return the alias set of the element for incomplete array
types, but do not remember these.
* gfortran.dg/pr32921.f: New testcase.
Index: alias.c
===================================================================
*** alias.c (revision 129486)
--- alias.c (working copy)
*************** get_alias_set (tree t)
*** 611,616 ****
--- 611,628 ----
if (TYPE_ALIAS_SET_KNOWN_P (t))
return TYPE_ALIAS_SET (t);
+ /* We don't want to set TYPE_ALIAS_SET for incomplete types. */
+ if (!COMPLETE_TYPE_P (t))
+ {
+ /* For arrays with unknown size the conservative answer is the
+ alias set of the element type. */
+ if (TREE_CODE (t) == ARRAY_TYPE)
+ return get_alias_set (TREE_TYPE (t));
+
+ /* But return zero as a conservative answer for incomplete types. */
+ return 0;
+ }
+
/* See if the language has special handling for this type. */
set = lang_hooks.get_alias_set (t);
if (set != -1)
Index: testsuite/gfortran.dg/pr32921.f
===================================================================
*** testsuite/gfortran.dg/pr32921.f (revision 0)
--- testsuite/gfortran.dg/pr32921.f (revision 0)
***************
*** 0 ****
--- 1,49 ----
+ ! { dg-do compile }
+ ! { dg-options "-O2 -fdump-tree-lim" }
+ ! gfortran -c -m32 -O2 -S junk.f
+ !
+ MODULE LES3D_DATA
+
+ IMPLICIT REAL*8 (A-H,O-Z)
+
+ PARAMETER ( NSPECI = 1, ND = 7 + NSPECI )
+
+ INTEGER IMAX
+
+ DOUBLE PRECISION,ALLOCATABLE,DIMENSION(:,:,:) ::
+ > UAV,QAV
+
+
+ END MODULE LES3D_DATA
+ !---------------------------------------------------------------------
+ !------------------------------------------------------------------------
+ SUBROUTINE FLUXI()
+
+ USE LES3D_DATA
+ IMPLICIT REAL*8(A-H,O-Z)
+
+ ALLOCATABLE QS(:)
+
+ ALLOCATE( QS(0:IMAX))
+ QS=0D0
+
+ RETURN
+ END
+ !------------------------------------------------------------------------
+ !------------------------------------------------------------------------
+ SUBROUTINE EXTRAPI()
+
+ USE LES3D_DATA
+ IMPLICIT REAL*8(A-H,O-Z)
+
+ I1 = 0
+ I2 = IMAX - 1
+
+ DO I = I1, I2
+ UAV(I,1,2) = QAV(I,1,2)
+ END DO
+
+ RETURN
+ END
+ ! { dg-final { scan-tree-dump-times "stride" 6 "lim" } }
+ ! { dg-final { cleanup-tree-dump "lim" } }
Index: stor-layout.c
===================================================================
*** stor-layout.c (revision 129486)
--- stor-layout.c (working copy)
*************** layout_type (tree type)
*** 1886,1898 ****
&& TREE_CODE (type) != QUAL_UNION_TYPE)
finalize_type_size (type);
! /* If an alias set has been set for this aggregate when it was incomplete,
! force it into alias set 0.
! This is too conservative, but we cannot call record_component_aliases
! here because some frontends still change the aggregates after
! layout_type. */
! if (AGGREGATE_TYPE_P (type) && TYPE_ALIAS_SET_KNOWN_P (type))
! TYPE_ALIAS_SET (type) = 0;
}
/* Create and return a type for signed integers of PRECISION bits. */
--- 1886,1895 ----
&& TREE_CODE (type) != QUAL_UNION_TYPE)
finalize_type_size (type);
! /* We should never see alias sets on incomplete aggregates. And we
! should not call layout_type on not incomplete aggregates. */
! if (AGGREGATE_TYPE_P (type))
! gcc_assert (!TYPE_ALIAS_SET_KNOWN_P (type));
}
/* Create and return a type for signed integers of PRECISION bits. */