Patchwork [IRA] Fix a function accessing beyond end-of-array

login
register
mail settings
Submitter Hariharan Sandanagobalane
Date May 11, 2011, 1:03 p.m.
Message ID <4DCA8926.9030106@picochip.com>
Download mbox | patch
Permalink /patch/95187/
State New
Headers show

Comments

Hariharan Sandanagobalane - May 11, 2011, 1:03 p.m.
Hello,
I discussed this problem with Vlad in 
http://gcc.gnu.org/ml/gcc/2011-05/msg00131.html. I propose the following 
patch to fix it. Okay to commit?

Thanks
Hari

ChangeLog:
        * ira.c (clarify_prohibited_class_mode_regs): It was running 
beyond the end of REGNO_REG_CLASS array. Fixed.

Patch:
           for (nregs-- ;nregs >= 0; nregs--)
             if (((enum reg_class) pclass
Eric Botcazou - May 11, 2011, 1:52 p.m.
>         * ira.c (clarify_prohibited_class_mode_regs): It was running
> beyond the end of REGNO_REG_CLASS array. Fixed.

This isn't a valid ChangeLog entry.  It must not state the "why" (it was 
running beyond the end of REGNO_REG_CLASS array), only the "what".  So you 
need to describe how you're fixing the problem, e.g. "Do not access the array 
if ..." or "Stop the loop if ...".  See the numerous examples in ChangeLog.

Patch

Index: gcc/ira.c
===================================================================
--- gcc/ira.c   (revision 173654)
+++ gcc/ira.c   (working copy)
@@ -1422,6 +1422,12 @@ 
           if (TEST_HARD_REG_BIT (ira_prohibited_class_mode_regs[cl][j], 
hard_regno))
             continue;
           nregs = hard_regno_nregs[hard_regno][j];
+          if (hard_regno + nregs >= FIRST_PSEUDO_REGISTER)
+            {
+              SET_HARD_REG_BIT (ira_prohibited_class_mode_regs[cl][j],
+                                hard_regno);
+               continue;
+            }
           pclass = ira_pressure_class_translate[REGNO_REG_CLASS 
(hard_regno)];