From patchwork Wed May 11 14:07:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hariharan Sandanagobalane X-Patchwork-Id: 95243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5D2121007D5 for ; Thu, 12 May 2011 13:34:40 +1000 (EST) 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:07:22 +0100 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 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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: for (nregs-- ;nregs >= 0; nregs--) if (((enum reg_class) pclass 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)];