This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa]: Patch to add component_ref ref's
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Nov 2002 21:58:32 -0500
- Subject: Re: [tree-ssa]: Patch to add component_ref ref's
- Organization: Red Hat Canada
- References: <Pine.LNX.4.44.0211210059570.7007-100000@dberlin.org>
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
refs.
> 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
case:
-----------------------------------------------------------------------------
1 struct A
2 {
3 int a;
4 int b;
5 };
6
7 int foo (struct A);
8
9 main()
10 {
11 struct A a, b;
12
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.
Diego.