RFA: patch to solve PR41241

Vladimir Makarov vmakarov@redhat.com
Thu Sep 3 18:18:00 GMT 2009


Vladimir Makarov wrote:
>
>>
>> Valgrind reports:
>>
>> ==7192== Invalid read of size 1
>> ==7192==    at 0x7291F8: reg_preferred_class (in 
>> /space/rguenther/obj/gcc/cc1)
>> ==7192==    by 0x6A95AC: rest_of_handle_ira (in 
>> /space/rguenther/obj/gcc/cc1)
>>
>> maybe that's it.  Does it ring a bell?
>>
>>   
> Sure, it is wrong.  It should be fixed.  Could you send the test case.
>

  The following patch fixes PR41241
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41241).  The problem was
triggered by the new patches.  Update_equiv_reg imported from the old
RA used initialized preferred reg class of pseudo in the following
fragment.

  /* ??? The mn10200 port breaks if we add equivalences for
     values that need an ADDRESS_REGS register and set them equivalent
     to a MEM of a pseudo.  The actual problem is in the over-conservative
     handling of INPADDR_ADDRESS / INPUT_ADDRESS / INPUT triples in
     calculate_needs, but we traditionally work around this problem
     here by rejecting equivalences when the destination is in a register
     that's likely spilled.  This is fragile, of course, since the
     preferred class of a pseudo depends on all instructions that set
     or use it.  */

  if (!REG_P (dest)
      || (regno = REGNO (dest)) < FIRST_PSEUDO_REGISTER
      || reg_equiv[regno].init_insns == const0_rtx
      || (CLASS_LIKELY_SPILLED_P (reg_preferred_class (regno))
      && MEM_P (src) && ! reg_equiv[regno].is_arg_equivalence))

At this stage of IRA the preferred and alternative register classes is
not defined yet.  So I've just removed the code containing
reg_preferred_class.  This code is predated by 1999.  It was very
fragile fix for mn10200.  The right solution would be fixing it in
reload and hope it was fixed because the fix here was very very
fragile.  I think it was just work around, not a real solution of the
problem.  Also this target (mn10200) is not supported anymore.  I do
not exclude that some weird target might be broken.  But I think the
probability of this is very low.  And if it happens, the problem
should be fixed in reload.

The patch removes the valgrind errors and was successfully
bootstrapped on 2 machines x86 and x86_64.

Ok to commit it into the trunk?

2009-09-03  Vladimir Makarov  <vmakarov@redhat.com>

    PR bootstrap/41241
    * ira.c (update_equiv_reg): Remove check on class likely spill.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr41241.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090903/f35202a1/attachment.ksh>


More information about the Gcc-patches mailing list