From patchwork Mon Nov 15 20:21:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 71281 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 23C55B711C for ; Tue, 16 Nov 2010 07:21:42 +1100 (EST) Received: (qmail 1893 invoked by alias); 15 Nov 2010 20:21:38 -0000 Received: (qmail 1882 invoked by uid 22791); 15 Nov 2010 20:21:37 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CF, 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; Mon, 15 Nov 2010 20:21:25 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAFKLAEn005292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Nov 2010 15:21:11 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oAFKL9IO032044 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 15 Nov 2010 15:21:10 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oAFKL90m016157; Mon, 15 Nov 2010 21:21:09 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oAFKL8UL016155; Mon, 15 Nov 2010 21:21:08 +0100 Date: Mon, 15 Nov 2010 21:21:08 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou , Paolo Bonzini Subject: [PATCH] Fix combiner cfglayout issue (PR rtl-optimization/46440) Message-ID: <20101115202108.GE29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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! On this testcase we ICE during flow checking, because combiner replaced an indirect jump (which was before going into cfglayout mode followed by BARRIER, which stays in the footer) by direct unconditional jump. Fixed by removing the BARRIER from the footer in that case. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Alternatively, perhaps the current_ir_type () == IR_RTL_CFGLAYOUT test can be assumed to be 1. 2010-11-15 Jakub Jelinek PR rtl-optimization/46440 * combine.c (update_cfg_for_uncondjump): When changing an indirect jump into unconditional jump, remove BARRIERs from bb's footer. * gcc.dg/pr46440.c: New test. Jakub --- gcc/combine.c.jj 2010-11-09 13:58:30.000000000 +0100 +++ gcc/combine.c 2010-11-15 13:53:13.000000000 +0100 @@ -2460,7 +2460,28 @@ update_cfg_for_uncondjump (rtx insn) delete_insn (insn); if (at_end && EDGE_COUNT (bb->succs) == 1) - single_succ_edge (bb)->flags |= EDGE_FALLTHRU; + { + single_succ_edge (bb)->flags |= EDGE_FALLTHRU; + + if (current_ir_type () == IR_RTL_CFGLAYOUT) + { + rtx insn; + + /* Remove barriers from the footer if there are any. */ + for (insn = bb->il.rtl->footer; insn; insn = NEXT_INSN (insn)) + if (BARRIER_P (insn)) + { + if (PREV_INSN (insn)) + NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); + else + bb->il.rtl->footer = NEXT_INSN (insn); + if (NEXT_INSN (insn)) + PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); + } + else if (LABEL_P (insn)) + break; + } + } } /* Try to combine the insns I0, I1 and I2 into I3. --- gcc/testsuite/gcc.dg/pr46440.c.jj 2010-11-15 14:12:53.000000000 +0100 +++ gcc/testsuite/gcc.dg/pr46440.c 2010-11-15 14:12:45.000000000 +0100 @@ -0,0 +1,25 @@ +/* PR rtl-optimization/46440 */ +/* { dg-do compile } */ +/* { dg-options "-O -fstack-protector -fno-tree-dominator-opts -fno-tree-fre" } */ +/* { dg-require-effective-target fstack_protector } */ + +int i; + +void bar (char *); + +void +foo (void) +{ + void *l; + char c[64]; + bar (c); + i = 1; + if (i) + l = &&l1; + else + l = &&l2; + goto *l; +l2: + __builtin_abort (); +l1:; +}