[PATCH] fix out of bound access on hard_regno_nregs

Graham Stott graham.stott@btinternet.com
Sun Dec 19 17:25:00 GMT 2004


All,

int
true_regnum (rtx x)
{
   ...

   if (GET_CODE (x) == SUBREG)
     {
       int base = true_regnum (SUBREG_REG (x));
       if (base >= 0 && base < FIRST_PSEUDO_REGISTER)
         return base + subreg_regno_offset (REGNO (SUBREG_REG (x)),
                                            GET_MODE (SUBREG_REG (x)),
                                            SUBREG_BYTE (x), GET_MODE (x));
     }
   return -1;
}


On 2nd reading it looks like we do have a bug in true_regnum.

Assume that X is a SUBREG whos reg is a pseudo_register that has been renumbered
then it looks like we should be passing BASE and not REGNO (SUBREG_REG (x)) onto
subreg_regno_offset.

Thoughts?

Graham



More information about the Gcc-patches mailing list