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] for PR17474


On Tue, 2004-09-21 at 07:00, Zdenek Dvorak wrote:
> Hello,
> 
> > > hmmm.... using arr as a type mem tag seems to just work.  Creating new
> > > type tag will not just work.  It would also be necessary to create the
> > > ssa form for it (adding phi nodes wherever phi nodes for arr are, etc.).
> > > It just does not seem to be worth the trouble.
> > > 
> > It is worth the trouble.  Do not hack the alias system like this.  It
> > will find a way of biting you back.
> 
> what about just giving the decls separate TMT from the beginning, and
> not using them in virtual operands?
>
If a pointer is never dereferenced, then creating a tag for it is just a
waste of memory.

>   This seems to solve the problem,
> and also it would be cleaner -- the only things that would occur
> as virtual operands would then be memory tags.
> 
You would get even worse alias relations this way.  This is documented
in tree-ssa-alias.c and the internals documentation (IIRC).  Suppose
that pointer 'p' may point to 'a' or 'b':

a = 2;
b = 6;
 = a;
 = *p;

Since 'a' and 'b' are aliased to *p, we can't treat them as regular
gimple regs.  OTOH, you don't want stores to 'a' or 'b' to affect each
other.  So, if we implemented the approach you propose we would have to
do:

tag for p is TMT.1
may-alias (a) = { TMT.1 }
may-alias (b) = { TMT.1 }

# V_MAY_DEF <TMT.1>
a = 2;
# V_MAY_DEF <TMT.1>
b = 6;
# VUSE <TMT.1>
 = a
# VUSE <TMT.1>
 = *p;

Note how the store to 'b' has killed the previous store to 'a'. 
Instead, what we do is:

tag for p is TMT.1
may-alias (TMT.1) = { a, b }

# V_MAY_DEF <a>
a = 2;
# V_MAY_DEF <b>
b = 6;
# VUSE <a>
 = a;
# VUSE <a>
# VUSE <b>
 = *p;

Now we have 'a' and 'b' not affecting each other.

I've been thinking about the original problem a little bit and I can't
convince myself that it's fundamentally unsafe to make 'arr' the type
tag for 'tmp'.  However, suppose that we had triggered the alias
grouping heuristic (which reverses the roles of type tags and aliased
variables) and 'arr' had ended up with several aliased symbols in its
may-alias set.  Now your loads and stores to *tmp end up using all these
symbols that you know have nothing to do with 'arr'.

So, if you create a type tag for 'tmp' and make 'arr' the tag's only
alias, you will avoid this situation.  Granted, if we had triggered the
alias grouping heuristic, that function is pretty hopeless to begin
with.



Diego.


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