[PATCH] Remove redundant checking from may_propagate_copy, allow copyprop through (void *) conversion

Richard Guenther rguenther@suse.de
Tue Sep 4 15:08:00 GMT 2007


On Tue, 4 Sep 2007, Daniel Berlin wrote:

> On 9/4/07, Richard Guenther <rguenther@suse.de> wrote:
> > On Tue, 4 Sep 2007, Richard Guenther wrote:
> >
> > >
> > > This removes redundant checking done by may_propagate_copy.  First it
> > > calls useless_type_conversion_p twice, second it does compare alias set
> > > numbers which useless_type_conversion_p does as well.  As
> > > useless_type_conversion_p special-cases conversions to (void *) this
> > > enables us to copypropagate in the testcase added.
> > >
> > > Bootstrapping and testing on x86_64-unknown-linux-gnu in progress.
> >
> > And the following actually passed bootstrapping and testing.  I'll
> > install after the usual wait-for-comments.  The new testcase would
> > ICE in the assert in get_smt_for if we didn't specialize VOID_TYPE
> > there (I tried to avoid generating a SMT for void, but that was too
> > tricky).
> 
> But why does the alias set for our tag not match the alias set for void *?
> 
> It seems like a bug otherwise.

For void (not void*).  It is because we special-case conversion to (void*)
so for

static struct typeinfo *typevec;
void ggc_set_mark (struct typeinfo*);
void gt_ggc_ma_typevec (void)
{
  if (typevec != ((void *)0))
    {
      void *a__ = typevec;
      ggc_set_mark (a__);
    }
}

we end up with (before the alias run in PRE):

gt_ggc_ma_typevec ()
{
  struct typeinfo * a__.1;

<bb 2>:
  # VUSE <typevec_4(D)>
  a__.1_1 = typevec;
  if (a__.1_1 != 0B)
    goto <bb 3>;
  else
    goto <bb 5>;

<bb 5>:
  goto <bb 4>;

<bb 3>:
  # SMT.7_6 = VDEF <SMT.7_5(D)>
  ggc_set_mark (a__.1_1);

during PTA we create a constraint

typevec = &ANYTHING
a__.1_1 = typevec 
derefaddrtmp.15 = &ANYTHING
*a__.1_1 = derefaddrtmp.15

Changing the prototype of ggc_set_mark to take a (struct typeinfo *)
would have fixed the ICE.  But I fail to see how the formal parameter
type (if pointer) makes a difference at all (for the alias solution).

We still somehow try to match *a__.1_1 to *(void *) for call parameters.
Why?

Richard.



More information about the Gcc-patches mailing list