[trunk][patch] fix another invalid sharing in see

Ian Lance Taylor iant@google.com
Mon May 26 20:18:00 GMT 2008


"Rafael Espindola" <espindola@google.com> writes:

> The bug reappeared with another test (attached). The problem is on the
> lines of what you think it is.  Before replace_rtx, ref_copy has the
> node "(reg:SI 62 [ a ])" in two places. After it, the subreg is
> present in those 2 places.
>
> I can see 3 options:
> 1) ref_copy was already invalid and we should no be sharing "(reg:SI 62 [ a ])"
> 2) replace_rtx should create copies of "to" when replacing in more
> then one place.
> 3) we have to fix ref_copy after replace_rtx.
>
> I like 1, but verify_rtx_sharing says REGs can be shared, so there
> might be a good reason for it. Changing replace_rtx sounds tempting,
> but I am afraid to break something else.


> +  /* It is possible for dest_reg to appear multiple times in ref_copy. In this
> +     case, ref_copy now has invalid sharing. Copying solves the problem. */
> +  ref_copy = copy_rtx (ref_copy);

How about instead doing:
    reset_used_flags (ref_copy);
    ref_copy = copy_rtx_if_shared (ref_copy);
That should avoid always generating garbage for an unlikely scenario.

Also, I suspect you only need to do this after the comment
  /* The manipulation succeeded.  Store the new manipulated reference.  */
If we don't reach that comment, ref_copy is discarded.

Ian



More information about the Gcc-patches mailing list