From patchwork Wed Jun 23 10:02:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 56626 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 DBA4CB6F14 for ; Wed, 23 Jun 2010 20:02:25 +1000 (EST) Received: (qmail 4681 invoked by alias); 23 Jun 2010 10:02:23 -0000 Received: (qmail 4571 invoked by uid 22791); 23 Jun 2010 10:02:22 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Jun 2010 10:02:17 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5NA2GYu017963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Jun 2010 06:02:16 -0400 Received: from Gift.redhat.com (vpn2-11-91.ams2.redhat.com [10.36.11.91]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5NA2DDi020618; Wed, 23 Jun 2010 06:02:14 -0400 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: RFA: Make compare_and_jump_seq check that it has a jump insn Date: Wed, 23 Jun 2010 11:02:13 +0100 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes 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 Hi Guys, I ran into a problem with the compare_and_jump_seq function in loop-unswitch.c yesterday. It was calling do_compare_rtx_and_jump which was returning a sequence of insns, the last of which was not a jump bit rather a label. Now I am not sure if do_compare_rtx_and_jump is required to return a jump insn as the last insn one the sequence, but I do know that compare_and_jump_seq assumes this to be true. The problem is that compare_and_jump_seq was then using the JUMP_LABEL macro on an insn that was not a jump, and in the process corrupting a completely unrelated insn. (It took me a *long* time to track down exactly where this corruption was occurring...). So I would like to propose the patch below to add an assertion to check that the insn really is a jump before setting the label. (An alternative idea would be to have the function scan backwards through the sequence of instructions until it finds the real jump insn. Not sure which is better). Checked by building an i686-pc-linux-gnu toolchain. OK to apply ? Cheers Nick gcc/ChangeLog 2010-06-23 Nick Clifton * loop-unswitch.c (compare_and_jump_seq): Assert that the last insn in the sequence is a jump insn before setting its label. Index: gcc/loop-unswitch.c =================================================================== --- gcc/loop-unswitch.c (revision 161254) +++ gcc/loop-unswitch.c (working copy) @@ -110,6 +110,7 @@ gcc_assert (rtx_equal_p (op1, XEXP (cond, 1))); emit_jump_insn (copy_insn (PATTERN (cinsn))); jump = get_last_insn (); + gcc_assert (JUMP_P (jump)); JUMP_LABEL (jump) = JUMP_LABEL (cinsn); LABEL_NUSES (JUMP_LABEL (jump))++; redirect_jump (jump, label, 0); @@ -123,6 +124,7 @@ do_compare_rtx_and_jump (op0, op1, comp, 0, mode, NULL_RTX, NULL_RTX, label, -1); jump = get_last_insn (); + gcc_assert (JUMP_P (jump)); JUMP_LABEL (jump) = label; LABEL_NUSES (label)++; }