This is the mail archive of the 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: [tree-ssa]: Patch to add component_ref ref's

On Thu, 21 Nov 2002, Daniel Berlin wrote:

> The partial defs are only necessary so that a full structure use (ie 
> a = b, where b is a structure) gets the right reaching definition when 
> it's fields are defined.  If one felt like teaching SSA-CCP this, and 
> making the optimizers know this in general, you could remove the partial 
> defs.
You will also need to model partial uses.  See below.  In fact,
what if we made the structure a may-alias of all its fields?
That way, we wouldn't have to create additional /partial
references and could model it using the may-alias handling in the
SSA builder.  I seem to remember discussing this with you
privately, but I don't recall why we decided to keep the partial

> Creating the right references at the right times  under these constraints 
> is not easy, thus, the extra argument to find_refs_in_expr.
> The main trick cases are involving component_refs with array and 
> indirect refs embedded in them (thus, the reason we can't just *not* 
> recurse, instead, we have to just skip creating refs for that part).
I'm not sure I understand this.  Could you include an example?

> Clobbering due to union *field* assignment is not implemented right now, 
> but it's trivial to add (In fact, if the rest of this patch is okay, I can 
> add it before committing it).
OK.  But the same principle as the partial refs applies.  Could
we not make the union fields alias of each other instead of
creating extra references?

I've not looked at the code yet.  But consider the following

     1	struct A
     2	{
     3	  int a;
     4	  int b;
     5	};
     7	int foo (struct A);
     9	main()
    10	{
    11	  struct A a, b;
    13	  a.a = 5;
    14	  a.b = 6;
    15	  foo (a);
    16	  b = a;
    17	}

Both definitions to a.a and a.b get no uses.  This is wrong
because DCE will remove both assignments.  Also, the assignment
to a.b is clobbering a.a?  That makes no sense.

Variable: a.a
    V_DEF(a.a): line 13, bb 0, id 1, a.a = 5 immediate uses:

    V_DEF/clobber(a.a): line 14, bb 0, id 3, a.b = 6 immediate uses:

Variable: a.b
    V_DEF(a.b): line 14, bb 0, id 4, a.b = 6 immediate uses:

I'm starting to think that /partial needs to disappear.  We
should model that with the may-alias mechanism.

Also, if you make b an alias for b.a and b.b, then the assignment
to b at line 16 will naturally reach any uses of b.a and b.b that
may exist after it.


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