From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10057 invoked by alias); 11 Jul 2011 09:08:43 -0000 Received: (qmail 10048 invoked by uid 22791); 11 Jul 2011 09:08:42 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from c60.cesmail.net (HELO c60.cesmail.net) (216.154.195.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Jul 2011 09:08:26 +0000 Received: from unknown (HELO epsilon2) ([192.168.1.60]) by c60.cesmail.net with ESMTP; 11 Jul 2011 05:08:25 -0400 Received: from e178024218.adsl.alicedsl.de (e178024218.adsl.alicedsl.de [85.178.24.218]) by webmail.spamcop.net (Horde MIME library) with HTTP; Mon, 11 Jul 2011 05:08:25 -0400 Message-ID: <20110711050825.zohqma67z4kso844-nzlynne@webmail.spamcop.net> Date: Mon, 11 Jul 2011 09:36:00 -0000 From: Joern Rennecke To: gcc-patches@gcc.gnu.org Subject: RFA: Fix bug in optimize_mode_switching MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_1o41v25ewjnt" Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.1.4) 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-07/txt/msg00788.txt.bz2 This message is in MIME format. --=_1o41v25ewjnt Content-Type: text/plain; charset=ISO-8859-15; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-length: 380 I work on target with complex mode switching needs, so it can happen that in some block, for an entity a mode is provided without the need for a set. This causes the current optimize_mode_switching to crash when it later dereferences a NULL seginfo pointer. Fixed by using an actual flag to keep track if we have allocated any seginfo. Bootstrappded on x86_64-unknown-linux-gnu. --=_1o41v25ewjnt Content-Type: text/plain; charset=UTF-8; name="mode-switch-fix" Content-Disposition: inline; filename="mode-switch-fix" Content-Transfer-Encoding: quoted-printable Content-length: 1478 2011-07-08 Joern Rennecke * mode-switching.c (optimize_mode_switching): Fix bug in MODE_AFTER handling. Index: mode-switching.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- mode-switching.c (revision 1670) +++ mode-switching.c (revision 1671) @@ -499,6 +499,7 @@ optimize_mode_switching (void) { struct seginfo *ptr; int last_mode =3D no_mode; + bool any_set_required =3D false; HARD_REG_SET live_now; =20 REG_SET_TO_HARD_REG_SET (live_now, df_get_live_in (bb)); @@ -527,6 +528,7 @@ optimize_mode_switching (void) =20 if (mode !=3D no_mode && mode !=3D last_mode) { + any_set_required =3D true; last_mode =3D mode; ptr =3D new_seginfo (mode, insn, bb->index, live_now); add_seginfo (info + bb->index, ptr); @@ -548,8 +550,10 @@ optimize_mode_switching (void) } =20 info[bb->index].computing =3D last_mode; - /* Check for blocks without ANY mode requirements. */ - if (last_mode =3D=3D no_mode) + /* Check for blocks without ANY mode requirements. + N.B. because of MODE_AFTER, last_mode might still be different + from no_mode. */ + if (!any_set_required) { ptr =3D new_seginfo (no_mode, BB_END (bb), bb->index, live_now); add_seginfo (info + bb->index, ptr); --=_1o41v25ewjnt--