From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25903 invoked by alias); 11 May 2011 14:07:56 -0000 Received: (qmail 25894 invoked by uid 22791); 11 May 2011 14:07:55 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from gw-ba1.picochip.com (HELO thurne.picochip.com) (94.175.234.108) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 May 2011 14:07:41 +0000 Received: from haddeo.picochip.com (haddeo.ubc.picochip.com [172.18.3.47]) (authenticated bits=0) by thurne.picochip.com (8.13.8/8.13.8) with ESMTP id p4BE7A4P007297; Wed, 11 May 2011 15:07:10 +0100 Message-ID: <4DCA981A.5010902@picochip.com> Date: Wed, 11 May 2011 15:27:00 -0000 From: Hari Sandanagobalane User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100720 Fedora/3.1.1-1.fc13 Lightning/1.0b2pre Thunderbird/3.1.1 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" , Vladimir Makarov , ebotcazou@adacore.com Subject: [Patch, IRA] Fix a function accessing beyond end-of-array Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg00846.txt.bz2 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