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 PR32921, prune virtual operands of memory accesses based on TBAA


On Fri, 19 Oct 2007, Richard Guenther wrote:

> Ok, it get's more complicated.  First of all, we need to handle
> the may_alias attribute.  That's easy enough, just add
> 
>       /* If the inner reference has alias set zero, we cannot use the
>          type of the access for TBAA purposes.  This happens with
>          the use of attribute may_alias.  */
>       && (!base || get_alias_set (TREE_TYPE (base)) != 0)
> 
> The bad thing is that Fortran gives arrays of real8 alias set zero
> for example.  For a reason I still need to investigate.  So this
> no longer fixes PR32921.

This happens in layout_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;
}

which forces the alias set of real8[0:] to zero.

#0  layout_type (type=0x2adc4ab090d0)
    at /space/rguenther/src/svn/pointer_plus/gcc/stor-layout.c:1896
#1  0x0000000000ac32f6 in build_array_type (elt_type=0x2adc4aa7d680, 
    index_type=0x2adc4aa8a1a0)
    at /space/rguenther/src/svn/pointer_plus/gcc/tree.c:5669

  if (!COMPLETE_TYPE_P (t))
    layout_type (t);

#2  0x00000000004f3475 in gfc_get_array_type_bounds (etype=0x2adc4aa7d680, 
    dimen=3, lbound=0x7fff6009e7b0, ubound=0x7fff6009e770, packed=0)
    at 
/space/rguenther/src/svn/pointer_plus/gcc/fortran/trans-types.c:1510

  /* We define data as an unknown size array. Much better than doing
     pointer arithmetic.  */
  arraytype =
    build_array_type (etype, gfc_array_range_type);


Now, we set the alias set of real8[0:] during gimplification which
calls useless_type_conversion_p which calls get_alias_set.  This
is really unfortunate as it probably also happens for other languages
and would explain why PR32921 shows up with r126326 which added these
calls to useless_type_conversion_p.

This can be fixed by either delaying gimplification or by not marking
real8[0:] as incomplete type (it really is not incomplete as of
layouting).  COMPLETE_TYPE_P is defined as

/* Nonzero if this type is a complete type.  */
#define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE)

but it looks like build_array_type wants to check
!COMPLETE_OR_UNBOUND_ARRAY_TYPE_P () instead?

Richard.


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