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: [tuples] dereference POINTER_PLUS_EXPR check


On Nov 21, 2007 11:58 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> On Wed, Nov 21, 2007 at 10:57:30PM +0100, Richard Guenther wrote:
> > On Nov 21, 2007 10:52 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> > > > Maybe we could make this a helper in tree.c.  Something like
> > > > pointed_to_type().  I don't think one exists already, but I may be wrong.
> > >
> > > Things are a bit cleaner now too, bonus!
> > >
> > > Is this OK?
> >
> > No, sorry.  It doesn't make sense to check the pointed-to types.  Or do you
> > say the modify expr embeds a de-reference?
>
> The modify_expr now embeds a POINTER_PLUS_EXPR.
>
> Where previously we had:
>
>         (MODIFY_EXPR lhs (POINTER_PLUS_EXPR rhs1 rhs2))
>
> We now have:
>
>         (GIMPLE_ASSIGN lhs rhs1 rhs2)
>
> with the POINTER_PLUS_EXPR in the subcode of the GIMPLE_ASSIGN.  We have
> collapsed the MODIFY_EXPR and the POINTER_PLUS_EXPR nodes into one
> tuple.

Yes.  This is what I thought.

> Previously, we would verify type sanity by checking the type of the LHS
> (which should be a pointer) with the type of the P_P_E.

Previously we had an additional type available, the type of the result
of the P_P_E.  What we checked is that the first argument of the PPE
is a pointer, that the second argument is convertible to sizetype and
that the first argument is convertible to the result type.

With tuples the result type is now simply the type of the lhs of the
MODIFY_EXPR.
Previously for the GIMPLE_MODIFY_STMT it hold that

  useless_type_conversion (lhs, rhs)

and for the P_P_E we had

  useless_type_conversion (rhs, op0)

now due to the transitiveness of u_t_c, we now simply need to check

  useless_type_conversion (lhs, op0)

which in your notation is lhs and rhs1.  Which is exactly what the code did
before your patch.

>  We no longer
> have the P_P_E with its type, so now we must look at the pointed-to
> types of both lhs and rhs1.

Why are the pointed-to types relevant at all?  Type relations for the
pointed-to types don't necessary translate to the relations of the
pointer types.
For example useless_type_conversion (void *, int *) == true but
useless_type_conversion (void, int) is certainly not true.

> Why do you think it doesn't make sense to look at the pointed-to types?

Because - pointed-to types don't have anything to do with the type validity
of a P_P_E.

Richard.


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