This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Introduce deep unsharing
On Fri, May 14, 2010 at 10:54 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Hum. ?But If you have a global type that has a complex size expression
>> you will have its TYPE_SIZES_GIMPLIFIED flag set after the first
>> function using it has been gimplified. ?Won't this cause problems for any
>> further functions? ?Or am I missing something?
>
> Yes, we mark global types (with TYPE_SIZES_GIMPLIFIED) and their size
> expressions (with TREE_VISITED) when we create them. ?So the expressions are
> unshared on the first reference in a function and the original trees are
> never unmarked since unsharing happens first. ?Therefore they are unshared
> again in another function and so on.
Hm, but then we modify trees that are visible elsewhere, correct? I can't
really see how gimplifying type-sizes of global types would work
multiple times.
>> So I can't see how SAVE_EXPRs or TARGET_EXPRs are any special to the
>> problem?
>
> Because they stop unsharing. ?The implicit assumption of the mark/unshare
> algorithm is that unsharing unshares a node and all its subtrees as soon as
> the node is visited twice; the subtrees aren't subsequently visited. ?If the
> subtrees contain themselves shared nodes, these nodes won't be unshared if
> there is a SAVE_EXPR or a TARGET_EXPR in-between.
Correct. Your patch is certainly a no-op for all languages but Ada,
but as we gimplify unit-at-a-time can't you do the necessary unsharing
from inside the frontend? I obviously miss something (and I will have a
look at the testcase and its dumps next week).
Richard.
> --
> Eric Botcazou
>