From patchwork Sat Jul 9 22:48:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 104036 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 F2D5CB71CE for ; Sun, 10 Jul 2011 08:48:42 +1000 (EST) Received: (qmail 27734 invoked by alias); 9 Jul 2011 22:48:41 -0000 Received: (qmail 27725 invoked by uid 22791); 9 Jul 2011 22:48:39 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from ra.se.axis.com (HELO ra.se.axis.com) (195.60.68.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 09 Jul 2011 22:48:25 +0000 Received: from localhost (localhost [127.0.0.1]) by ra.se.axis.com (Postfix) with ESMTP id B7A0911FA3 for ; Sun, 10 Jul 2011 00:48:22 +0200 (CEST) Received: from ra.se.axis.com ([127.0.0.1]) by localhost (ra.se.axis.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 1LrPHxx2evLw for ; Sun, 10 Jul 2011 00:48:22 +0200 (CEST) Received: from thoth.se.axis.com (thoth.se.axis.com [10.0.2.173]) by ra.se.axis.com (Postfix) with ESMTP id 03F1511F93 for ; Sun, 10 Jul 2011 00:48:21 +0200 (CEST) Received: from ignucius.se.axis.com (ignucius.se.axis.com [10.88.21.50]) by thoth.se.axis.com (Postfix) with ESMTP id E5E37340BB; Sun, 10 Jul 2011 00:48:21 +0200 (CEST) Received: from ignucius.se.axis.com (localhost [127.0.0.1]) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) with ESMTP id p69MmLF6005264; Sun, 10 Jul 2011 00:48:21 +0200 Received: (from hp@localhost) by ignucius.se.axis.com (8.12.8p1/8.12.8/Debian-2woody1) id p69MmLQL005260; Sun, 10 Jul 2011 00:48:21 +0200 Date: Sun, 10 Jul 2011 00:48:21 +0200 Message-Id: <201107092248.p69MmLQL005260@ignucius.se.axis.com> From: Hans-Peter Nilsson To: gcc-patches@gcc.gnu.org Subject: Committed: robustify CRIS ASM_OUTPUT_CASE_END MIME-Version: 1.0 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 The recent dwarf2 changes caused notes to be emitted between the CRIS (casesi expanded to sort-of) tablejump and the jump-table. I know RTH solved that particular problem another way (thanks!), but the documented adjacency promise is about of instructions, not notes, so it seems appropriate to also commit this tested solution hopefully avoiding some future surprises. And if something happens, we have a chance to catch it as an internal error rather than hoping for a SEGV. PR bootstrap/49680 * config/cris/cris.c (cris_asm_output_case_end): Robustify against stray notes and debug insns by using prev_nonnote_nondebug_insn instead of PREV_INSN. brgds, H-P Index: config/cris/cris.c =================================================================== --- config/cris/cris.c (revision 175272) +++ config/cris/cris.c (working copy) @@ -2275,12 +2275,22 @@ cris_legitimate_pic_operand (rtx x) void cris_asm_output_case_end (FILE *stream, int num, rtx table) { + /* Step back, over the label for the table, to the actual casejump and + assert that we find only what's expected. */ + rtx whole_jump_insn = prev_nonnote_nondebug_insn (table); + gcc_assert (whole_jump_insn != NULL_RTX && LABEL_P (whole_jump_insn)); + whole_jump_insn = prev_nonnote_nondebug_insn (whole_jump_insn); + gcc_assert (whole_jump_insn != NULL_RTX + && (JUMP_P (whole_jump_insn) + || (TARGET_V32 && INSN_P (whole_jump_insn) + && GET_CODE (PATTERN (whole_jump_insn)) == SEQUENCE))); + /* Get the pattern of the casejump, so we can extract the default label. */ + whole_jump_insn = PATTERN (whole_jump_insn); + if (TARGET_V32) { - rtx whole_jump_insn = PATTERN (PREV_INSN (PREV_INSN (table))); - /* This can be a SEQUENCE, meaning the delay-slot of the jump is - filled. */ + filled. We also output the offset word a little differently. */ rtx parallel_jump = (GET_CODE (whole_jump_insn) == SEQUENCE ? PATTERN (XVECEXP (whole_jump_insn, 0, 0)) : whole_jump_insn); @@ -2298,11 +2308,7 @@ cris_asm_output_case_end (FILE *stream, "\t.word %LL%d-%LL%d%s\n", CODE_LABEL_NUMBER (XEXP (XEXP - (XEXP - (XVECEXP - (PATTERN - (PREV_INSN - (PREV_INSN (table))), 0, 0), 1), + (XEXP (XVECEXP (whole_jump_insn, 0, 0), 1), 2), 0)), num, (TARGET_PDEBUG ? "; default" : ""));