public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, IRA] Fix a function accessing beyond end-of-array
@ 2011-05-11 15:27 Hari Sandanagobalane
  2011-05-11 18:20 ` Eric Botcazou
  2011-05-11 19:57 ` Vladimir Makarov
  0 siblings, 2 replies; 8+ messages in thread
From: Hari Sandanagobalane @ 2011-05-11 15:27 UTC (permalink / raw)
  To: gcc-patches, Vladimir Makarov, ebotcazou

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?

Revised the ChangeLog.

Thanks
Hari

ChangeLog:
         * ira.c (clarify_prohibited_class_mode_regs): Prevent the 
function from accessing beyond the end of REGNO_REG_CLASS array by 
stopping the loop early.

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)];
            for (nregs-- ;nregs >= 0; nregs--)
              if (((enum reg_class) pclass

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [Patch, IRA] Fix a function accessing beyond end-of-array
@ 2011-05-11 14:12 Hari Sandanagobalane
  2011-05-11 15:04 ` Eric Botcazou
  0 siblings, 1 reply; 8+ messages in thread
From: Hari Sandanagobalane @ 2011-05-11 14:12 UTC (permalink / raw)
  To: gcc-patches, Vladimir Makarov

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:
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)];
           for (nregs-- ;nregs >= 0; nregs--)
             if (((enum reg_class) pclass

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-05-12 11:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-11 15:27 [Patch, IRA] Fix a function accessing beyond end-of-array Hari Sandanagobalane
2011-05-11 18:20 ` Eric Botcazou
2011-05-11 19:57 ` Vladimir Makarov
2011-05-12 11:39   ` Hari Sandanagobalane
2011-05-12 12:12     ` Jakub Jelinek
2011-05-12 14:36       ` Hari Sandanagobalane
  -- strict thread matches above, loose matches on Subject: below --
2011-05-11 14:12 Hari Sandanagobalane
2011-05-11 15:04 ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).